Skip to content

Commit

Permalink
[api] always prompts on app destruction
Browse files Browse the repository at this point in the history
  • Loading branch information
blakmatrix committed Jan 15, 2013
1 parent 23cb2e6 commit 3e18806
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions lib/jitsu/commands/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,40 +543,38 @@ apps.update.usage = [
//
apps.destroy = function (name, callback) {

//
//
// Allows arbitrary amount of arguments
//
if(arguments.length) {
var args = utile.args(arguments);
callback = args.callback;
name = args[0] || null;
}

function executeDestroy() {
jitsu.log.info('Destroying app ' + name.magenta);
jitsu.apps.destroy(name, function (err) {
jitsu.log.silly('Done destroying app ' + name.magenta);
return err ? callback(err) : callback();
});
}

if (!name) {
jitsu.package.tryRead(process.cwd(), callback, function (pkg) {
jitsu.log.info('Attempting to destroy app ' + pkg.name.magenta);
name = pkg.name;
jitsu.prompt.confirm('yes/no', function(err, result){
if (result) {
executeDestroy();
} else {
jitsu.log.info('app ' + pkg.name.magenta + ' was not destroyed');
callback(null);
}
});
executeDestroy();
});
} else {
executeDestroy();
}

function executeDestroy() {
jitsu.log.info('Destroy app ' + name.magenta);
jitsu.prompt.confirm('yes/no', { default: 'yes'}, function(err, result){
if (result) {
jitsu.apps.destroy(name, function (err) {
jitsu.log.silly('Done destroying app ' + name.magenta);
return err ? callback(err) : callback();
});
} else {
jitsu.log.info('app ' + name.magenta + ' was not destroyed');
callback(null);
}
});
}
};

//
Expand Down

0 comments on commit 3e18806

Please sign in to comment.