@pi-r/gulp 0.2.3 → 0.2.8

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 +21 -18
  4. package/package.json +4 -4
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023 An Pham
1
+ Copyright 2023 Mile Square Park
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
4
+
5
+ ## LICENSE
4
6
 
5
7
  MIT
package/index.js CHANGED
@@ -8,13 +8,13 @@ const which = require("which");
8
8
  const types_1 = require("@e-mc/types");
9
9
  const Task = require('@e-mc/task');
10
10
  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 }) || '');
11
+ const BIN_GULP = Task.sanitizeCmd(which.sync("gulp", { nothrow: true }) || '');
12
12
  const REGEXP_TIMESTAMP = /^\[\d+:\d+:\d+\]$/;
13
13
  function executeTasks(assets, preceding, host) {
14
14
  if (this.aborted) {
15
15
  return Promise.reject((0, types_1.createAbortError)());
16
16
  }
17
- return this.allSettled(this.collate(assets, preceding), ['Execute tasks', "gulp" /* STRINGS.MODULE_NAME */]).then(result => {
17
+ return this.allSettled(this.collate(assets, preceding), ['Execute tasks', "gulp"]).then(result => {
18
18
  if (host) {
19
19
  for (const output of result) {
20
20
  if (output.status === 'fulfilled') {
@@ -31,11 +31,10 @@ function executeTasks(assets, preceding, host) {
31
31
  });
32
32
  }
33
33
  const normalizePath = (value) => process.platform === 'win32' ? '"' + value.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"' : Task.sanitizeArgs(value);
34
- // @ts-ignore
35
34
  class Gulp extends Task {
36
35
  constructor() {
37
36
  super(...arguments);
38
- this._moduleName = "gulp" /* STRINGS.MODULE_NAME */;
37
+ this._moduleName = "gulp";
39
38
  }
40
39
  static finalize(instance, assets) {
41
40
  return executeTasks.call(instance, assets, false, this);
@@ -56,7 +55,7 @@ class Gulp extends Task {
56
55
  const origDir = path.dirname(localUri);
57
56
  const scheduled = new Set();
58
57
  for (let { task, handler, preceding } of item.tasks) {
59
- if (task && handler === "gulp" /* STRINGS.MODULE_NAME */ && !!preceding === isPreceding) {
58
+ if (task && handler === "gulp" && !!preceding === isPreceding) {
60
59
  let gulpfile = (0, types_1.isString)(task) ? username && (0, types_1.isObject)(settings.users) && settings.users[username]?.[task] || settings[task] : task, tasks, opts;
61
60
  if ((0, types_1.isObject)(gulpfile)) {
62
61
  ({ path: gulpfile, tasks, opts } = gulpfile);
@@ -81,7 +80,7 @@ class Gulp extends Task {
81
80
  if (!(0, types_1.isString)(task)) {
82
81
  task = gulpfile && path.basename(gulpfile);
83
82
  }
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 */);
83
+ this.writeFail(["Unable to perform task", task ? "gulp" + ': ' + task : ''], (0, types_1.errorMessage)(task || "gulp", "Unknown", username), 4);
85
84
  }
86
85
  }
87
86
  }
@@ -181,7 +180,7 @@ class Gulp extends Task {
181
180
  spawn(gulp, callback) {
182
181
  const { task, origDir, data } = gulp;
183
182
  const tempDir = this.getTempDir({ uuidDir: true });
184
- const writeError = (value, err, hint, type = 32 /* LOG_TYPE.FILE */) => {
183
+ const writeError = (value, err, hint, type = 32) => {
185
184
  if (err) {
186
185
  this.writeFail([value, hint || (this.moduleName + ': ' + task)], err, { type, startTime });
187
186
  }
@@ -191,7 +190,7 @@ class Gulp extends Task {
191
190
  }
192
191
  };
193
192
  if (!tempDir) {
194
- writeError("Unable to create temp directory" /* ERR_MESSAGE.TEMP_DIRECTORY */, null, this.getTempDir());
193
+ writeError("Unable to create temp directory", null, this.getTempDir());
195
194
  return;
196
195
  }
197
196
  let { path: gulpfile, tasks, opts, items } = data;
@@ -236,7 +235,7 @@ class Gulp extends Task {
236
235
  }
237
236
  const startTime = process.hrtime();
238
237
  const broadcastId = this.broadcastId;
239
- this.formatMessage(4 /* LOG_TYPE.PROCESS */, "gulp" /* STRINGS.MODULE_NAME */, ['Executing task...', task], gulpfile);
238
+ this.formatMessage(4, "gulp", ['Executing task...', task], gulpfile);
240
239
  Promise.all(items.map(src => fs.promises.copyFile(src, path.join(tempDir, path.basename(src)))))
241
240
  .then(() => {
242
241
  try {
@@ -254,7 +253,7 @@ class Gulp extends Task {
254
253
  timeStamp = '';
255
254
  }
256
255
  };
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 })
256
+ 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
257
  .on('exit', code => {
259
258
  if (!code) {
260
259
  this.addLog(types_1.STATUS_TYPE.INFO, out);
@@ -283,14 +282,14 @@ class Gulp extends Task {
283
282
  --i;
284
283
  }
285
284
  else {
286
- this.writeFail(["Unable to rename file" /* ERR_MESSAGE.RENAME_FILE */, filename], err, 32 /* LOG_TYPE.FILE */);
285
+ this.writeFail(["Unable to rename file", filename], err, 32);
287
286
  }
288
287
  }
289
288
  }
290
- this.writeTimeProcess("gulp" /* STRINGS.MODULE_NAME */, task + ' -> ' + path.basename(items[0]), startTime);
289
+ this.writeTimeProcess("gulp", task + ' -> ' + path.basename(items[0]), startTime);
291
290
  }
292
291
  catch (err) {
293
- writeError("Unable to read directory" /* ERR_MESSAGE.READ_DIRECTORY */, err, false);
292
+ writeError("Unable to read directory", err, false);
294
293
  }
295
294
  items.forEach(value => !result.has(value) && (deleted || (deleted = [])).push(value));
296
295
  result.forEach(value => !items.includes(value) && (added || (added = [])).push(value));
@@ -298,10 +297,10 @@ class Gulp extends Task {
298
297
  callback({ added, deleted });
299
298
  }
300
299
  else {
301
- writeError("Unable to execute file" /* ERR_MESSAGE.EXECUTE_FILE */, new Error(message || "Unknown" /* ERR_MESSAGE.UNKNOWN */), '', 4 /* LOG_TYPE.PROCESS */);
300
+ writeError("Unable to execute file", new Error(message || "Unknown"), '', 4);
302
301
  }
303
302
  })
304
- .on('error', err => writeError("Unknown" /* ERR_MESSAGE.UNKNOWN */, err, false, 4 /* LOG_TYPE.PROCESS */));
303
+ .on('error', err => writeError("Unknown", err, false, 4));
305
304
  if (stdout) {
306
305
  stdout.setEncoding('utf-8').on('data', (value) => {
307
306
  if (broadcastId) {
@@ -320,11 +319,15 @@ class Gulp extends Task {
320
319
  }
321
320
  }
322
321
  catch (err) {
323
- writeError("Unable to execute file" /* ERR_MESSAGE.EXECUTE_FILE */, err);
322
+ writeError("Unable to execute file", err);
324
323
  }
325
324
  })
326
- .catch(err => writeError("Unable to copy file" /* ERR_MESSAGE.COPY_FILE */, err, tempDir));
325
+ .catch(err => writeError("Unable to copy file", err, tempDir));
327
326
  }
328
327
  }
328
+ exports.default = Gulp;
329
329
 
330
- module.exports = Gulp;
330
+ if (exports.default) {
331
+ module.exports = exports.default;
332
+ module.exports.default = exports.default;
333
+ }
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.8",
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.4",
24
+ "@e-mc/types": "^0.5.4",
25
25
  "gulp": "^4.0.2",
26
26
  "gulp-cli": "^2.3.0",
27
27
  "strip-ansi": "6.0.1",