As people who have migrated to Gulp 4 may know, gulp.series
– as it should – won't proceed with execution if a task in the series doesn't signal completion properly.
My problem with that is the way it handles this kind of error – it's simply a message in the console (Did you forget to signal async completion?); gulp still exits with an error code of 0. That means that if you run gulp inside a more complicated build script, to that script it will look like if everything was alright and gulp tasks completed successfully when they clearly didn't. (In contrast, if you throw an error with gulpUtil.plugin error
, it results in a non-0 error code.)
So my question is: how would you detect "from the outside" that such error have happened?
Is there any other possibility I didn't think of?
You can use the stream/Promise/callback to signal the process. Once the hand shake is done , you could proceed with the process.
var print = require('gulp-print');
gulp.task('message', function() {
return gulp.src('package.json')
.pipe(print(function() { return 'HTTP Server Started'; }));
});
gulp.task('message', function() {
return new Promise(function(resolve, reject) {
console.log("HTTP Server Started");
resolve();
});
});
gulp.task('message', function(done) {
console.log("HTTP Server Started");
done();
});
else use call backs in this fashion.
function syncTasks(callback1)
{
return gulp.series(firstTask, secondTask, (callback2) =>
{
callback1();
callback2();
})();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With