我正在努力做到这一点,如果未指定 --theme 标志,它会停止 gulp 任务并想知道以 DRY 方式完成它的最佳方法。
如果未指定 --theme,我希望每个单独的任务都停止,如果不满足,我也希望默认任务停止。
到目前为止,我已经尝试了一些没有运气的事情。
谢谢,
gulp.task('test', function() {
if(typeof(args.theme) == 'undefined' || args.theme === true) {
console.log(msg.noTheme);
return; // end task
}
// run rest of task...
});
gulp.task('test-2', function() {
if(typeof(args.theme) == 'undefined' || args.theme === true) {
console.log(msg.noTheme);
return; // end task
}
// run rest of task...
});
gulp.task('default', ['test-1', 'test-2']);
最佳答案
您可以简单地停止脚本:
process.exit()
关于javascript - 如果满足条件,停止 Gulp 任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28485162/