升级到 Gulp 4 时发出异步完成警告信号
Signal async completion warning upon upgrade to Gulp 4
我使用 Gulp 来 运行 非 JavaScript 项目中的一项简单任务。我正在尝试从 3.9.1 升级到 4.0 以摆脱 "deprecated" 和 "security" 警告的泛滥。连同像 A quick guide for switching to gulp 4 I've upgraded locally, dropped gulp-util
这样的文章,最后是 package.json
:
{
"name": "redacted",
"main": "gulpfile.js",
"private": true,
"devDependencies": {
"ansi-colors": "^3.0.5",
"fancy-log": "^1.3.2",
"gulp": "^4.0.0",
"gulp-zip": "^4.2.0",
"temp": "^0.8.3"
}
}
但我不是 Node.js 专家,我显然遗漏了一些东西。我的旧式任务:
var gulp = require('gulp');
var log = require('fancy-log');
gulp.task('hi', function() {
log('Hello, World!');
});
… 触发器:
PS D:\Redacted> gulp hi
[10:25:58] Using gulpfile D:\Redacted\gulpfile.js
[10:25:58] Starting 'hi'...
[10:25:58] Hello, World!
[10:25:58] The following tasks did not complete: hi
[10:25:58] Did you forget to signal async completion?
如果我按照文章的建议注入 gulp.series()
并删除匿名函数:
function hi() {
log('Hello, World!');
}
gulp.task('hi', gulp.series(hi));
... 然后任务 运行s 两次或其输出显示两次(不确定)但警告仍然存在:
PS D:\Redacted> gulp hi
[10:28:47] Using gulpfile D:\Redacted\gulpfile.js
[10:28:47] Starting 'hi'...
[10:28:47] Starting 'hi'...
[10:28:47] Hello, World!
[10:28:47] The following tasks did not complete: hi, hi
[10:28:47] Did you forget to signal async completion?
我错过了什么?有没有更好的升级指南?
旧式语法仍然有效。我显然只是错过了对 done 回调的最终调用,在 Gulp/3:
上似乎不需要该回调
gulp.task('hi', function(done){
log('Hello, World!');
done();
});
gulp.series()
对于 运行 单个任务来说似乎有点矫枉过正。
我使用 Gulp 来 运行 非 JavaScript 项目中的一项简单任务。我正在尝试从 3.9.1 升级到 4.0 以摆脱 "deprecated" 和 "security" 警告的泛滥。连同像 A quick guide for switching to gulp 4 I've upgraded locally, dropped gulp-util
这样的文章,最后是 package.json
:
{
"name": "redacted",
"main": "gulpfile.js",
"private": true,
"devDependencies": {
"ansi-colors": "^3.0.5",
"fancy-log": "^1.3.2",
"gulp": "^4.0.0",
"gulp-zip": "^4.2.0",
"temp": "^0.8.3"
}
}
但我不是 Node.js 专家,我显然遗漏了一些东西。我的旧式任务:
var gulp = require('gulp');
var log = require('fancy-log');
gulp.task('hi', function() {
log('Hello, World!');
});
… 触发器:
PS D:\Redacted> gulp hi
[10:25:58] Using gulpfile D:\Redacted\gulpfile.js
[10:25:58] Starting 'hi'...
[10:25:58] Hello, World!
[10:25:58] The following tasks did not complete: hi
[10:25:58] Did you forget to signal async completion?
如果我按照文章的建议注入 gulp.series()
并删除匿名函数:
function hi() {
log('Hello, World!');
}
gulp.task('hi', gulp.series(hi));
... 然后任务 运行s 两次或其输出显示两次(不确定)但警告仍然存在:
PS D:\Redacted> gulp hi
[10:28:47] Using gulpfile D:\Redacted\gulpfile.js
[10:28:47] Starting 'hi'...
[10:28:47] Starting 'hi'...
[10:28:47] Hello, World!
[10:28:47] The following tasks did not complete: hi, hi
[10:28:47] Did you forget to signal async completion?
我错过了什么?有没有更好的升级指南?
旧式语法仍然有效。我显然只是错过了对 done 回调的最终调用,在 Gulp/3:
上似乎不需要该回调gulp.task('hi', function(done){
log('Hello, World!');
done();
});
gulp.series()
对于 运行 单个任务来说似乎有点矫枉过正。