本文介紹了如果滿足條件,則停止 Gulp 任務(wù)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
限時(shí)送ChatGPT賬號(hào)..
我正在嘗試這樣做,因此如果未指定 --theme 標(biāo)志,它會(huì)停止 gulp 任務(wù)并想知道以 DRY 方式執(zhí)行此任務(wù)的最佳方法.
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,我希望每個(gè)單獨(dú)的任務(wù)停止,并且如果未滿足,我希望默認(rèn)任務(wù)停止.
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.
到目前為止,我已經(jīng)嘗試了一些沒(méi)有運(yùn)氣的事情.
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']);
推薦答案
您可以簡(jiǎn)單地停止腳本:
You can simply stop the script with:
process.exit()
這篇關(guān)于如果滿足條件,則停止 Gulp 任務(wù)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!