如果条件得到满足,停止Gulp任务 [英] Stop Gulp Task if Conditions are met
本文介绍了如果条件得到满足,停止Gulp任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图做到这一点,如果没有指定-theme标志,它会停止吞咽任务,并想知道以干的方式做到这一点的最佳方式。
I am trying to make it so if a --theme flag isn't specified it stops the gulp task and wondering the best way to do it in a DRY way.
如果未指定-theme,并且如果未满足默认任务,我希望每个任务都停止。
I would like each individual task to stop if a --theme isn't specified and also have the default task stop if it isn't met.
I到目前为止没有运气的尝试了几件事。
I have tried a few things with no luck so far.
谢谢,
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']);
推荐答案
您可以简单地停止脚本:
You can simply stop the script with:
process.exit()
这篇关于如果条件得到满足,停止Gulp任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文