mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-31 19:16:58 +00:00
354921ca92
This prevents a lot of duplicate code to check for confirmation status and exit from the current action.
34 lines
688 B
JavaScript
34 lines
688 B
JavaScript
(function() {
|
|
var Promise, form;
|
|
|
|
Promise = require('bluebird');
|
|
|
|
form = require('resin-cli-form');
|
|
|
|
exports.selectDeviceType = function() {
|
|
return form.ask({
|
|
message: 'Device Type',
|
|
type: 'list',
|
|
choices: ['Raspberry Pi', 'Raspberry Pi 2', 'BeagleBone Black']
|
|
});
|
|
};
|
|
|
|
exports.confirm = function(yesOption, message) {
|
|
return Promise["try"](function() {
|
|
if (yesOption) {
|
|
return true;
|
|
}
|
|
return form.ask({
|
|
message: message,
|
|
type: 'confirm',
|
|
"default": false
|
|
});
|
|
}).then(function(confirmed) {
|
|
if (!confirmed) {
|
|
throw new Error('Aborted');
|
|
}
|
|
});
|
|
};
|
|
|
|
}).call(this);
|