2017-07-18 2 views
1

Ich benutze Cordova mit einem Haken auf after_prepare. Ich möchte beenden, wenn der Befehl nicht korrekt ist.Wie beende ich einen "cordova build" -Befehl von einem Haken?

Zum Beispiel dieser Befehl korrekt ist:

cordova run android --ENV=PRD 

Dieses ist falsch, und ich möchte, dass die Lebensdauer von Cordova unterbrochen werden:

cordova run android --ENV=AEZAZEZ 

Mein Haken wie folgt aussieht:

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 { 

Wie ändert man einen Haken, um den Befehl Cordova run zu beenden?

Antwort

3

eine nicht behandelte Ausnahme Wurf:

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