@pi-r/gulp 0.3.1 → 0.3.3
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.
- package/LICENSE +1 -1
- package/README.md +4 -2
- package/index.js +16 -18
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright 2023
|
|
1
|
+
Copyright 2023 Lisa Mishima
|
|
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
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"
|
|
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"
|
|
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"
|
|
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"
|
|
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"
|
|
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
|
|
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"
|
|
192
|
+
writeError("Unable to create temp directory", null, this.getTempDir());
|
|
195
193
|
return;
|
|
196
194
|
}
|
|
197
195
|
const exec = this.settings.exec;
|
|
@@ -246,7 +244,7 @@ class Gulp extends Task {
|
|
|
246
244
|
}
|
|
247
245
|
const startTime = process.hrtime();
|
|
248
246
|
const broadcastId = this.broadcastId;
|
|
249
|
-
this.formatMessage(4
|
|
247
|
+
this.formatMessage(4, "gulp", ['Executing task...', task], gulpfile);
|
|
250
248
|
Promise.all(items.map(src => fs.promises.copyFile(src, path.join(tempDir, path.basename(src)))))
|
|
251
249
|
.then(() => {
|
|
252
250
|
try {
|
|
@@ -264,7 +262,7 @@ class Gulp extends Task {
|
|
|
264
262
|
timeStamp = '';
|
|
265
263
|
}
|
|
266
264
|
};
|
|
267
|
-
const { stdout, stderr } = child_process.spawn(BIN_GULP || BIN_NPX, args, { cwd: process.cwd(), shell: true, stdio: Task.hasLogType(32768
|
|
265
|
+
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, uid, gid })
|
|
268
266
|
.on('exit', code => {
|
|
269
267
|
if (!code) {
|
|
270
268
|
this.addLog(types_1.STATUS_TYPE.INFO, out);
|
|
@@ -293,14 +291,14 @@ class Gulp extends Task {
|
|
|
293
291
|
--i;
|
|
294
292
|
}
|
|
295
293
|
else {
|
|
296
|
-
this.writeFail(["Unable to rename file"
|
|
294
|
+
this.writeFail(["Unable to rename file", filename], err, 32);
|
|
297
295
|
}
|
|
298
296
|
}
|
|
299
297
|
}
|
|
300
|
-
this.writeTimeProcess("gulp"
|
|
298
|
+
this.writeTimeProcess("gulp", task + ' -> ' + path.basename(items[0]), startTime);
|
|
301
299
|
}
|
|
302
300
|
catch (err) {
|
|
303
|
-
writeError("Unable to read directory"
|
|
301
|
+
writeError("Unable to read directory", err, false);
|
|
304
302
|
}
|
|
305
303
|
items.forEach(value => !result.has(value) && (deleted || (deleted = [])).push(value));
|
|
306
304
|
result.forEach(value => !items.includes(value) && (added || (added = [])).push(value));
|
|
@@ -308,10 +306,10 @@ class Gulp extends Task {
|
|
|
308
306
|
callback({ added, deleted });
|
|
309
307
|
}
|
|
310
308
|
else {
|
|
311
|
-
writeError("Unable to execute file"
|
|
309
|
+
writeError("Unable to execute file", new Error(message || "Unknown"), '', 4);
|
|
312
310
|
}
|
|
313
311
|
})
|
|
314
|
-
.on('error', err => writeError("Unknown"
|
|
312
|
+
.on('error', err => writeError("Unknown", err, false, 4));
|
|
315
313
|
if (stdout) {
|
|
316
314
|
stdout.setEncoding('utf-8').on('data', (value) => {
|
|
317
315
|
if (broadcastId) {
|
|
@@ -330,10 +328,10 @@ class Gulp extends Task {
|
|
|
330
328
|
}
|
|
331
329
|
}
|
|
332
330
|
catch (err) {
|
|
333
|
-
writeError("Unable to execute file"
|
|
331
|
+
writeError("Unable to execute file", err);
|
|
334
332
|
}
|
|
335
333
|
})
|
|
336
|
-
.catch(err => writeError("Unable to copy file"
|
|
334
|
+
.catch(err => writeError("Unable to copy file", err, tempDir));
|
|
337
335
|
}
|
|
338
336
|
}
|
|
339
337
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/gulp",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
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.6.
|
|
24
|
-
"@e-mc/types": "^0.6.
|
|
23
|
+
"@e-mc/task": "^0.6.2",
|
|
24
|
+
"@e-mc/types": "^0.6.2",
|
|
25
25
|
"gulp": "^4.0.2",
|
|
26
26
|
"gulp-cli": "^2.3.0",
|
|
27
27
|
"strip-ansi": "6.0.1",
|