Dán*_*agy 5 terminal error-code gulp gulp-4
正如已经迁移到Gulp 4的人可能知道的gulp.series那样 - 如果系列中的任务没有正确地表示完成,则不会继续执行.
我的问题是它处理这种错误的方式 - 它只是控制台中的一条消息(你忘了发信号异步完成吗?) ; gulp仍然以错误代码0退出.这意味着如果你在一个更复杂的构建脚本中运行gulp,那么看起来好像一切都没问题,并且当他们显然没有成功完成gulp任务时.(相反,如果抛出错误gulpUtil.plugin error,则会导致非0错误代码.)
所以我的问题是:你如何从外部发现这样的错误?
还有其他我没想过的可能性吗?
您可以使用流/Promise/回调来向进程发出信号。握手完成后,您就可以继续该过程。
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();
});
Run Code Online (Sandbox Code Playgroud)
否则以这种方式使用回调。
function syncTasks(callback1)
{
return gulp.series(firstTask, secondTask, (callback2) =>
{
callback1();
callback2();
})();
}
Run Code Online (Sandbox Code Playgroud)