检查 runSequence 是否失败

check if runSequence fail

我的 gulpfile 中有以下任务:

gulp.task('build', function (cb) {
  return runSequence(
    'clean',
    'tsd',
    'ts-lint',
    ['sass', 'copy-assets', 'ts-compile', 'templates', 'copy-vendor'],
    'karma-once',
    'index',
    cb
  );
});

如何检查 runSequence 中的任何任务是否一口气失败?

runSequence 接受的回调函数作为最后一个参数,如果某些任务失败,会给你一个 err 对象。

runSequence('mytask', ['othertask'], function(err) {
    if (err) {
        // you can check for err.message or err.task for the name of the task
    }
});