@pi-r/gulp 0.2.3 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +4 -2
  3. package/index.js +16 -18
  4. package/package.json +4 -4
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 An Pham
1
+ Copyright 2020-24 Code Geass
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
- ### @pi-r/gulp
1
+ # @pi-r/gulp
2
2
 
3
- ### LICENSE
3
+ PEP 402 - Forever Josee + Nunnally
4
+
5
+ ## LICENSE
4
6
 
5
7
  MIT
package/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  const path = require("path");
4
3
  const fs = require("fs");
5
4
  const child_process = require("child_process");
@@ -8,13 +7,13 @@ const which = require("which");
8
7
  const types_1 = require("@e-mc/types");
9
8
  const Task = require('@e-mc/task');
10
9
  const BIN_NPX = Task.sanitizeCmd(which.sync('npx', { nothrow: true }) || 'npx');
11
- const BIN_GULP = Task.sanitizeCmd(which.sync("gulp" /* STRINGS.MODULE_NAME */, { nothrow: true }) || '');
10
+ const BIN_GULP = Task.sanitizeCmd(which.sync("gulp", { nothrow: true }) || '');
12
11
  const REGEXP_TIMESTAMP = /^\[\d+:\d+:\d+\]$/;
13
12
  function executeTasks(assets, preceding, host) {
14
13
  if (this.aborted) {
15
14
  return Promise.reject((0, types_1.createAbortError)());
16
15
  }
17
- return this.allSettled(this.collate(assets, preceding), ['Execute tasks', "gulp" /* STRINGS.MODULE_NAME */]).then(result => {
16
+ return this.allSettled(this.collate(assets, preceding), ['Execute tasks', "gulp"]).then(result => {
18
17
  if (host) {
19
18
  for (const output of result) {
20
19
  if (output.status === 'fulfilled') {
@@ -31,11 +30,10 @@ function executeTasks(assets, preceding, host) {
31
30
  });
32
31
  }
33
32
  const normalizePath = (value) => process.platform === 'win32' ? '"' + value.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"' : Task.sanitizeArgs(value);
34
- // @ts-ignore
35
33
  class Gulp extends Task {
36
34
  constructor() {
37
35
  super(...arguments);
38
- this._moduleName = "gulp" /* STRINGS.MODULE_NAME */;
36
+ this._moduleName = "gulp";
39
37
  }
40
38
  static finalize(instance, assets) {
41
39
  return executeTasks.call(instance, assets, false, this);
@@ -56,7 +54,7 @@ class Gulp extends Task {
56
54
  const origDir = path.dirname(localUri);
57
55
  const scheduled = new Set();
58
56
  for (let { task, handler, preceding } of item.tasks) {
59
- if (task && handler === "gulp" /* STRINGS.MODULE_NAME */ && !!preceding === isPreceding) {
57
+ if (task && handler === "gulp" && !!preceding === isPreceding) {
60
58
  let gulpfile = (0, types_1.isString)(task) ? username && (0, types_1.isObject)(settings.users) && settings.users[username]?.[task] || settings[task] : task, tasks, opts;
61
59
  if ((0, types_1.isObject)(gulpfile)) {
62
60
  ({ path: gulpfile, tasks, opts } = gulpfile);
@@ -81,7 +79,7 @@ class Gulp extends Task {
81
79
  if (!(0, types_1.isString)(task)) {
82
80
  task = gulpfile && path.basename(gulpfile);
83
81
  }
84
- this.writeFail(["Unable to perform task" /* ERR_MESSAGE.PERFORM_TASK */, task ? "gulp" /* STRINGS.MODULE_NAME */ + ': ' + task : ''], (0, types_1.errorMessage)(task || "gulp" /* STRINGS.MODULE_NAME */, "Unknown" /* ERR_MESSAGE.UNKNOWN */, username), 4 /* LOG_TYPE.PROCESS */);
82
+ this.writeFail(["Unable to perform task", task ? "gulp" + ': ' + task : ''], (0, types_1.errorMessage)(task || "gulp", "Unknown", username), 4);
85
83
  }
86
84
  }
87
85
  }
@@ -181,7 +179,7 @@ class Gulp extends Task {
181
179
  spawn(gulp, callback) {
182
180
  const { task, origDir, data } = gulp;
183
181
  const tempDir = this.getTempDir({ uuidDir: true });
184
- const writeError = (value, err, hint, type = 32 /* LOG_TYPE.FILE */) => {
182
+ const writeError = (value, err, hint, type = 32) => {
185
183
  if (err) {
186
184
  this.writeFail([value, hint || (this.moduleName + ': ' + task)], err, { type, startTime });
187
185
  }
@@ -191,7 +189,7 @@ class Gulp extends Task {
191
189
  }
192
190
  };
193
191
  if (!tempDir) {
194
- writeError("Unable to create temp directory" /* ERR_MESSAGE.TEMP_DIRECTORY */, null, this.getTempDir());
192
+ writeError("Unable to create temp directory", null, this.getTempDir());
195
193
  return;
196
194
  }
197
195
  let { path: gulpfile, tasks, opts, items } = data;
@@ -236,7 +234,7 @@ class Gulp extends Task {
236
234
  }
237
235
  const startTime = process.hrtime();
238
236
  const broadcastId = this.broadcastId;
239
- this.formatMessage(4 /* LOG_TYPE.PROCESS */, "gulp" /* STRINGS.MODULE_NAME */, ['Executing task...', task], gulpfile);
237
+ this.formatMessage(4, "gulp", ['Executing task...', task], gulpfile);
240
238
  Promise.all(items.map(src => fs.promises.copyFile(src, path.join(tempDir, path.basename(src)))))
241
239
  .then(() => {
242
240
  try {
@@ -254,7 +252,7 @@ class Gulp extends Task {
254
252
  timeStamp = '';
255
253
  }
256
254
  };
257
- const { stdout, stderr } = child_process.spawn(BIN_GULP || BIN_NPX, args, { cwd: process.cwd(), shell: true, stdio: Task.hasLogType(32768 /* LOG_TYPE.STDOUT */) && !broadcastId ? 'inherit' : undefined, signal: this.signal })
255
+ const { stdout, stderr } = child_process.spawn(BIN_GULP || BIN_NPX, args, { cwd: process.cwd(), shell: true, stdio: Task.hasLogType(32768) && !broadcastId ? 'inherit' : undefined, signal: this.signal })
258
256
  .on('exit', code => {
259
257
  if (!code) {
260
258
  this.addLog(types_1.STATUS_TYPE.INFO, out);
@@ -283,14 +281,14 @@ class Gulp extends Task {
283
281
  --i;
284
282
  }
285
283
  else {
286
- this.writeFail(["Unable to rename file" /* ERR_MESSAGE.RENAME_FILE */, filename], err, 32 /* LOG_TYPE.FILE */);
284
+ this.writeFail(["Unable to rename file", filename], err, 32);
287
285
  }
288
286
  }
289
287
  }
290
- this.writeTimeProcess("gulp" /* STRINGS.MODULE_NAME */, task + ' -> ' + path.basename(items[0]), startTime);
288
+ this.writeTimeProcess("gulp", task + ' -> ' + path.basename(items[0]), startTime);
291
289
  }
292
290
  catch (err) {
293
- writeError("Unable to read directory" /* ERR_MESSAGE.READ_DIRECTORY */, err, false);
291
+ writeError("Unable to read directory", err, false);
294
292
  }
295
293
  items.forEach(value => !result.has(value) && (deleted || (deleted = [])).push(value));
296
294
  result.forEach(value => !items.includes(value) && (added || (added = [])).push(value));
@@ -298,10 +296,10 @@ class Gulp extends Task {
298
296
  callback({ added, deleted });
299
297
  }
300
298
  else {
301
- writeError("Unable to execute file" /* ERR_MESSAGE.EXECUTE_FILE */, new Error(message || "Unknown" /* ERR_MESSAGE.UNKNOWN */), '', 4 /* LOG_TYPE.PROCESS */);
299
+ writeError("Unable to execute file", new Error(message || "Unknown"), '', 4);
302
300
  }
303
301
  })
304
- .on('error', err => writeError("Unknown" /* ERR_MESSAGE.UNKNOWN */, err, false, 4 /* LOG_TYPE.PROCESS */));
302
+ .on('error', err => writeError("Unknown", err, false, 4));
305
303
  if (stdout) {
306
304
  stdout.setEncoding('utf-8').on('data', (value) => {
307
305
  if (broadcastId) {
@@ -320,10 +318,10 @@ class Gulp extends Task {
320
318
  }
321
319
  }
322
320
  catch (err) {
323
- writeError("Unable to execute file" /* ERR_MESSAGE.EXECUTE_FILE */, err);
321
+ writeError("Unable to execute file", err);
324
322
  }
325
323
  })
326
- .catch(err => writeError("Unable to copy file" /* ERR_MESSAGE.COPY_FILE */, err, tempDir));
324
+ .catch(err => writeError("Unable to copy file", err, tempDir));
327
325
  }
328
326
  }
329
327
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/gulp",
3
- "version": "0.2.3",
3
+ "version": "0.2.9",
4
4
  "description": "Gulp task constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/anpham6/pi-r.git",
11
+ "url": "git+https://github.com/anpham6/pi-r.git",
12
12
  "directory": "src/module/gulp"
13
13
  },
14
14
  "keywords": [
@@ -20,8 +20,8 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/pi-r#readme",
22
22
  "dependencies": {
23
- "@e-mc/task": "^0.5.3",
24
- "@e-mc/types": "^0.5.3",
23
+ "@e-mc/task": "^0.5.5",
24
+ "@e-mc/types": "^0.5.5",
25
25
  "gulp": "^4.0.2",
26
26
  "gulp-cli": "^2.3.0",
27
27
  "strip-ansi": "6.0.1",