问题
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