I use Gulp to run one simple task in a non-JavaScript project. I'm trying to upgrade from 3.9.1 to 4.0 to get rid of the flood of "deprecated" and "security" warnings. Together with articles like A quick guide for switching to gulp 4 I've upgraded locally, dropped gulp-util
and ended up with this 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"
}
}
But I'm not a Node.js expert and I'm clearly missing something. My old style tasks:
var gulp = require('gulp');
var log = require('fancy-log');
gulp.task('hi', function() {
log('Hello, World!');
});
… trigger:
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?
If I inject gulp.series()
and get rid of anonymous functions as the article recommends:
function hi() {
log('Hello, World!');
}
gulp.task('hi', gulp.series(hi));
… then either the task runs twice or its output gets displayed twice (not sure) but the warning persists:
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?
What bit am I missing? Is there a better upgrade guide?
The old-fashioned syntax still works. I was apparently just missing a final call to the done callback that didn't seem to be required on Gulp/3:
gulp.task('hi', function(done){
log('Hello, World!');
done();
});
gulp.series()
looks like overkill for running a single task.