本文介紹了如果滿足條件,則停止 Gulp 任務的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
我正在嘗試這樣做,因此如果未指定 --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 任務的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!