mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-03-10 22:44:14 +00:00
Merge pull request #174 from resin-io/jviotti/feature/confirm-abortion
Add `Aborted` error message when not accepting a confirmation
This commit is contained in:
commit
d10d4ce185
@ -80,10 +80,7 @@
|
|||||||
options: [commandOptions.yes],
|
options: [commandOptions.yes],
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return helpers.confirm(option.yes, 'Are you sure you want to delete the application?').then(function(confirmed) {
|
return helpers.confirm(options.yes, 'Are you sure you want to delete the application?').then(function() {
|
||||||
if (!confirmed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return resin.models.application.remove(params.name);
|
return resin.models.application.remove(params.name);
|
||||||
}).nodeify(done);
|
}).nodeify(done);
|
||||||
}
|
}
|
||||||
@ -106,10 +103,7 @@
|
|||||||
var message;
|
var message;
|
||||||
message = "Are you sure you want to associate " + currentDirectory + " with " + params.name + "?";
|
message = "Are you sure you want to associate " + currentDirectory + " with " + params.name + "?";
|
||||||
return helpers.confirm(options.yes, message);
|
return helpers.confirm(options.yes, message);
|
||||||
}).then(function(confirmed) {
|
}).then(function() {
|
||||||
if (!confirmed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return resin.models.application.get(params.name).get('git_repository').then(function(gitRepository) {
|
return resin.models.application.get(params.name).get('git_repository').then(function(gitRepository) {
|
||||||
return vcs.initialize(currentDirectory).then(function() {
|
return vcs.initialize(currentDirectory).then(function() {
|
||||||
return vcs.associate(currentDirectory, gitRepository);
|
return vcs.associate(currentDirectory, gitRepository);
|
||||||
|
@ -75,10 +75,7 @@
|
|||||||
options: [commandOptions.yes],
|
options: [commandOptions.yes],
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return helpers.confirm(options.yes, 'Are you sure you want to delete the device?').then(function(confirmed) {
|
return helpers.confirm(options.yes, 'Are you sure you want to delete the device?').then(function() {
|
||||||
if (!confirmed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return resin.models.device.remove(params.uuid);
|
return resin.models.device.remove(params.uuid);
|
||||||
}).nodeify(done);
|
}).nodeify(done);
|
||||||
}
|
}
|
||||||
|
@ -56,10 +56,7 @@
|
|||||||
options: [commandOptions.yes, commandOptions.booleanDevice],
|
options: [commandOptions.yes, commandOptions.booleanDevice],
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return helpers.confirm(options.yes, 'Are you sure you want to delete the environment variable?').then(function(confirmed) {
|
return helpers.confirm(options.yes, 'Are you sure you want to delete the environment variable?').then(function() {
|
||||||
if (!confirmed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (options.device) {
|
if (options.device) {
|
||||||
return resin.models.environmentVariables.device.remove(params.id);
|
return resin.models.environmentVariables.device.remove(params.id);
|
||||||
} else {
|
} else {
|
||||||
|
@ -49,10 +49,7 @@
|
|||||||
options: [commandOptions.yes],
|
options: [commandOptions.yes],
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return helpers.confirm(options.yes, 'Are you sure you want to delete the key?').then(function(confirmed) {
|
return helpers.confirm(options.yes, 'Are you sure you want to delete the key?').then(function() {
|
||||||
if (!confirmed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return resin.models.key.remove(params.id);
|
return resin.models.key.remove(params.id);
|
||||||
}).nodeify(done);
|
}).nodeify(done);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,10 @@
|
|||||||
type: 'confirm',
|
type: 'confirm',
|
||||||
"default": false
|
"default": false
|
||||||
});
|
});
|
||||||
|
}).then(function(confirmed) {
|
||||||
|
if (!confirmed) {
|
||||||
|
throw new Error('Aborted');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -125,8 +125,7 @@ exports.remove =
|
|||||||
options: [ commandOptions.yes ]
|
options: [ commandOptions.yes ]
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
helpers.confirm(option.yes, 'Are you sure you want to delete the application?').then (confirmed) ->
|
helpers.confirm(options.yes, 'Are you sure you want to delete the application?').then ->
|
||||||
return if not confirmed
|
|
||||||
resin.models.application.remove(params.name)
|
resin.models.application.remove(params.name)
|
||||||
.nodeify(done)
|
.nodeify(done)
|
||||||
|
|
||||||
@ -157,9 +156,7 @@ exports.associate =
|
|||||||
.then ->
|
.then ->
|
||||||
message = "Are you sure you want to associate #{currentDirectory} with #{params.name}?"
|
message = "Are you sure you want to associate #{currentDirectory} with #{params.name}?"
|
||||||
helpers.confirm(options.yes, message)
|
helpers.confirm(options.yes, message)
|
||||||
|
.then ->
|
||||||
.then (confirmed) ->
|
|
||||||
return if not confirmed
|
|
||||||
|
|
||||||
resin.models.application.get(params.name).get('git_repository').then (gitRepository) ->
|
resin.models.application.get(params.name).get('git_repository').then (gitRepository) ->
|
||||||
vcs.initialize(currentDirectory).then ->
|
vcs.initialize(currentDirectory).then ->
|
||||||
|
@ -105,8 +105,7 @@ exports.remove =
|
|||||||
options: [ commandOptions.yes ]
|
options: [ commandOptions.yes ]
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
helpers.confirm(options.yes, 'Are you sure you want to delete the device?').then (confirmed) ->
|
helpers.confirm(options.yes, 'Are you sure you want to delete the device?').then ->
|
||||||
return if not confirmed
|
|
||||||
resin.models.device.remove(params.uuid)
|
resin.models.device.remove(params.uuid)
|
||||||
.nodeify(done)
|
.nodeify(done)
|
||||||
|
|
||||||
|
@ -82,9 +82,7 @@ exports.remove =
|
|||||||
]
|
]
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
helpers.confirm(options.yes, 'Are you sure you want to delete the environment variable?').then (confirmed) ->
|
helpers.confirm(options.yes, 'Are you sure you want to delete the environment variable?').then ->
|
||||||
return if not confirmed
|
|
||||||
|
|
||||||
if options.device
|
if options.device
|
||||||
resin.models.environmentVariables.device.remove(params.id)
|
resin.models.environmentVariables.device.remove(params.id)
|
||||||
else
|
else
|
||||||
|
@ -67,8 +67,7 @@ exports.remove =
|
|||||||
options: [ commandOptions.yes ]
|
options: [ commandOptions.yes ]
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
helpers.confirm(options.yes, 'Are you sure you want to delete the key?').then (confirmed) ->
|
helpers.confirm(options.yes, 'Are you sure you want to delete the key?').then ->
|
||||||
return if not confirmed
|
|
||||||
resin.models.key.remove(params.id)
|
resin.models.key.remove(params.id)
|
||||||
.nodeify(done)
|
.nodeify(done)
|
||||||
|
|
||||||
|
@ -21,3 +21,6 @@ exports.confirm = (yesOption, message) ->
|
|||||||
message: message
|
message: message
|
||||||
type: 'confirm'
|
type: 'confirm'
|
||||||
default: false
|
default: false
|
||||||
|
.then (confirmed) ->
|
||||||
|
if not confirmed
|
||||||
|
throw new Error('Aborted')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user