Stop Gulp Task if Conditions are met(如果满足条件,则停止 Gulp 任务)
问题描述
我正在尝试这样做,因此如果未指定 --theme 标志,它会停止 gulp 任务并想知道以 DRY 方式执行此任务的最佳方法.
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 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 任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如果满足条件,则停止 Gulp 任务


基础教程推荐
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01