pom421
pom421

Reputation: 1964

How to exit a "cordova build" command from a hook?

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 ?

Upvotes: 1

Views: 458

Answers (1)

DaveAlden
DaveAlden

Reputation: 30366

Throw an unhandled exception:

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

Upvotes: 4

Related Questions