Reputation: 6725
I have a gulp 3 file which I am trying to upgrade to gulp 4. When I do so some of the tasks work others dont. The three errors that i am getting are as follows:
clean-styles:
gulp.task('clean-styles', function (done) {
var files = config.temp + '**/*.css';
clean(files, done);
});
[23:47:05] The following tasks did not complete: clean-styles
[23:47:05] Did you forget to signal async completion?
scss-watcher:
gulp.task('scss-watcher', function () {
gulp.watch([config.scss], ['styles']);
});
[23:51:27] 'scss-watcher' errored after 2.46 ms
[23:51:27] Error: watching ./src/client/styles/styles.scss: watch task has to be a function (optionally generated by using gulp.parallel or gulp.series)
styles: (This will work if i remove the clean-styles series)
gulp.task('styles', gulp.series('clean-styles', function () {
log('Compiling SCSS --> CSS');
return gulp
.src(config.scss)
.pipe($.scss())
.pipe($.autoprefixer({ browsers: ['last 2 versions', '> 5%'] }))
.pipe(gulp.dest(config.temp));
}));
[23:52:42] The following tasks did not complete: styles, clean-styles
[23:52:42] Did you forget to signal async completion?
vet: (Works)
gulp.task('vet', function () {
log('Analyzing source with ESLint');
return gulp
.src(config.js)
.pipe($.if(args.verbose, $.print()))
.pipe($.eslint())
.pipe($.eslint.format())
.pipe($.eslint.failOnError());
});
functions:
function clean(path, done) {
log('Cleaning: ' + $.util.colors.blue(path));
del(path, done);
}
function log(msg) {
if (typeof(msg) === 'object') {
for (var item in msg) {
if (msg.hasOwnProperty(item)) {
$.util.log($.util.colors.blue(msg[item]));
}
}
}
else {
$.util.log($.util.colors.blue(msg));
}
}
I have to be missing something. Can anyone fill me in on what I am missing?
Upvotes: 2
Views: 3770
Reputation: 123
Friends, this is workaround this issue:
We need to call the callback functions(Task and Anonimous
function electronTask(callbackA)
{
return gulp.series(myFirstTask, mySeccondTask, (callbackB) =>
{
callbackA();
callbackB();
});
}
Upvotes: 1
Reputation: 30564
clean-styles
del
doesn't take a callback function. It returns a Promise
that you have to return in your task:
function clean(path) {
log('Cleaning: ' + $.util.colors.blue(path));
return del(path);
}
gulp.task('clean-styles', function () {
var files = config.temp + '**/*.css';
return clean(files);
});
scss-watcher
gulp.watch()
doesn't support arrays of task names anymore. You have to pass it a function, gulp.series()
or gulp.parallel()
:
gulp.task('scss-watcher', function () {
gulp.watch([config.scss], gulp.series('styles'));
});
styles
Should work with the changes to clean-styles
above.
Upvotes: 3