How to exit a “cordova build” command from a hook?

自闭症网瘾萝莉.ら 提交于 2020-07-22 07:55:53

问题


I use Cordova with a hook on after_prepare. I want to exit if the command is not correct.

For example, this command is correct :

cordova run android --ENV=PRD

This one is incorrect and I want the lifecycle of Cordova be interrupted :

cordova run android --ENV=AEZAZEZ

My hook looks like :

module.exports = function(ctx) {

var env     = ctx.opts.options.ENV;

if ( !CONFIG[env] ) {
    // there is a problem in the CLI, I want to exit

} else {

How to modify a hook to exit from Cordova run command ?


回答1:


Throw an unhandled exception:

if ( !CONFIG[env] ) {
    throw "there is a problem in the CLI, I want to exit";
} 


来源:https://stackoverflow.com/questions/45163424/how-to-exit-a-cordova-build-command-from-a-hook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!