mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-04-08 11:54:12 +00:00
allow passing --drive to resin device init
This commit is contained in:
parent
8d91a5732a
commit
ed83514a2f
@ -13,6 +13,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- Show a clear message immediately as the deploy starts, if we're deploying an image.
|
||||
- Allow OS version selection when doing `resin device init`
|
||||
- Actually tolerate the `--yes` param to `resin device init`
|
||||
- Allows passing `--drive` to `resin device init`
|
||||
|
||||
### Fixed
|
||||
|
||||
|
@ -271,7 +271,12 @@ exports.init = {
|
||||
}, _.assign({}, commandOptions.osVersion, {
|
||||
signature: 'os-version',
|
||||
parameter: 'os-version'
|
||||
})
|
||||
}), {
|
||||
signature: 'drive',
|
||||
description: 'the drive to write the image to, like /dev/sdb. Careful with this as you can erase your hard drive.',
|
||||
parameter: 'drive',
|
||||
alias: 'd'
|
||||
}
|
||||
],
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
@ -314,6 +319,9 @@ exports.init = {
|
||||
if (options.yes) {
|
||||
osInitCommand += ' --yes';
|
||||
}
|
||||
if (options.drive) {
|
||||
osInitCommand += " --drive " + options.drive;
|
||||
}
|
||||
return capitanoRunAsync(osInitCommand);
|
||||
})["catch"](function(error) {
|
||||
return resin.models.device.remove(device.uuid)["finally"](function() {
|
||||
|
@ -215,12 +215,10 @@ exports.initialize = {
|
||||
}
|
||||
});
|
||||
}).tap(function(answers) {
|
||||
var message;
|
||||
if (answers.drive == null) {
|
||||
return;
|
||||
}
|
||||
message = "This will erase " + answers.drive + ". Are you sure?";
|
||||
return patterns.confirm(options.yes, message)["return"](answers.drive).then(umountAsync);
|
||||
return patterns.confirm(options.yes, "This will erase " + answers.drive + ". Are you sure?", "Going to erase " + answers.drive + ".")["return"](answers.drive).then(umountAsync);
|
||||
}).tap(function(answers) {
|
||||
return helpers.sudo(['internal', 'osinit', params.image, options.type, JSON.stringify(answers)]);
|
||||
}).then(function(answers) {
|
||||
|
@ -100,9 +100,12 @@ exports.selectDeviceType = function() {
|
||||
});
|
||||
};
|
||||
|
||||
exports.confirm = function(yesOption, message) {
|
||||
exports.confirm = function(yesOption, message, yesMessage) {
|
||||
return Promise["try"](function() {
|
||||
if (yesOption) {
|
||||
if (yesMessage) {
|
||||
console.log(yesMessage);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return form.ask({
|
||||
|
@ -372,6 +372,14 @@ exports.init =
|
||||
alias: 'v'
|
||||
}
|
||||
_.assign({}, commandOptions.osVersion, { signature: 'os-version', parameter: 'os-version' })
|
||||
{
|
||||
signature: 'drive'
|
||||
description: 'the drive to write the image to, like /dev/sdb.
|
||||
Careful with this as you can erase your hard drive.
|
||||
'
|
||||
parameter: 'drive'
|
||||
alias: 'd'
|
||||
}
|
||||
]
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
@ -411,6 +419,8 @@ exports.init =
|
||||
osInitCommand = "os initialize '#{tempPath}' --type #{application.device_type}"
|
||||
if options.yes
|
||||
osInitCommand += ' --yes'
|
||||
if options.drive
|
||||
osInitCommand += " --drive #{options.drive}"
|
||||
capitanoRunAsync(osInitCommand)
|
||||
# Make sure the device resource is removed if there is an
|
||||
# error when configuring or initializing a device image
|
||||
|
@ -241,8 +241,11 @@ exports.initialize =
|
||||
drive: options.drive
|
||||
.tap (answers) ->
|
||||
return if not answers.drive?
|
||||
message = "This will erase #{answers.drive}. Are you sure?"
|
||||
patterns.confirm(options.yes, message)
|
||||
patterns.confirm(
|
||||
options.yes
|
||||
"This will erase #{answers.drive}. Are you sure?"
|
||||
"Going to erase #{answers.drive}."
|
||||
)
|
||||
.return(answers.drive)
|
||||
.then(umountAsync)
|
||||
.tap (answers) ->
|
||||
|
@ -76,9 +76,11 @@ exports.selectDeviceType = ->
|
||||
type: 'list'
|
||||
choices: deviceTypes
|
||||
|
||||
exports.confirm = (yesOption, message) ->
|
||||
exports.confirm = (yesOption, message, yesMessage) ->
|
||||
Promise.try ->
|
||||
return true if yesOption
|
||||
if yesOption
|
||||
console.log(yesMessage) if yesMessage
|
||||
return true
|
||||
return form.ask
|
||||
message: message
|
||||
type: 'confirm'
|
||||
|
Loading…
x
Reference in New Issue
Block a user