This should be easy... I am trying to create a notification that the del is done.
Del = https://www.npmjs.com/package/del
Notify = https://www.npmjs.com/package/gulp-notify
I have:
gulp.task('clean', function() {
return del(['distFolder']);
});
That clears everything in the distFolder before it gets rebuilt.
What I am trying to do is something like below:
gulp.task('clean', function() {
return del(['distFolder']).pipe(notify('Clean task finished'));
});
The above returns an error - "TypeError: del(...).pipe is not a function"
The key to getting this done right is that
del
returns a promise. So you have to handle the promise.I've created a gulpfile that has 3 tasks:
clean
illustrates how to do it.fail
illustrates the point of being able to handle failures.incorrect
replicates the method in the OP's self-answer It is incorrect becausedel
returns a promise object whether or not it is successful. So the&&
test will always evaluate the 2nd part of the expression and thus will always notifyClean Done!
even if there was an error and nothing was deleted.Here's the code: