update resin-device-init to pull in etcher-image-write

This commit is contained in:
Eugene Mirotin 2017-03-28 12:09:58 +03:00
parent 137473353c
commit 77b30409bb
5 changed files with 35 additions and 6 deletions

View File

@ -74,7 +74,7 @@ exports.getManifest = function(image, deviceType) {
};
exports.osProgressHandler = function(step) {
var bar, rindle, visuals;
var progressBars, rindle, visuals;
rindle = require('rindle');
visuals = require('resin-cli-visuals');
step.on('stdout', process.stdout.write.bind(process.stdout));
@ -85,7 +85,12 @@ exports.osProgressHandler = function(step) {
}
return console.log(exports.stateToString(state));
});
bar = new visuals.Progress('Writing Device OS');
step.on('burn', bar.update.bind(bar));
progressBars = {
write: new visuals.Progress('Writing Device OS'),
check: new visuals.Progress('Validating Device OS')
};
step.on('burn', function(state) {
return progressBars[state.type].update(state);
});
return rindle.wait(step);
};

View File

@ -79,6 +79,8 @@ module.exports =
# otherwise the question will not be asked because
# `false` is a defined value.
yes: options.yes || undefined
# TODO: dedupe with the resin-device-operations
.then (answers) ->
if answers.yes isnt true
console.log(chalk.red.bold('Aborted image flash'))

View File

@ -245,6 +245,22 @@ exports.initialize =
])
.then (answers) ->
return if not answers.drive?
# TODO: resin local makes use of ejectAsync, see below
# DO we need this / should we do that here?
# getDrive = (drive) ->
# driveListAsync().then (drives) ->
# selectedDrive = _.find(drives, device: drive)
# if not selectedDrive?
# throw new Error("Drive not found: #{drive}")
# return selectedDrive
# if (os.platform() is 'win32') and selectedDrive.mountpoint?
# ejectAsync = Promise.promisify(require('removedrive').eject)
# return ejectAsync(selectedDrive.mountpoint)
umountAsync(answers.drive).tap ->
console.info("You can safely remove #{answers.drive} now")
.nodeify(done)

View File

@ -83,8 +83,11 @@ exports.osProgressHandler = (step) ->
return if state.operation.command is 'burn'
console.log(exports.stateToString(state))
bar = new visuals.Progress('Writing Device OS')
progressBars =
write: new visuals.Progress('Writing Device OS')
check: new visuals.Progress('Validating Device OS')
step.on('burn', bar.update.bind(bar))
step.on 'burn', (state) ->
progressBars[state.type].update(state)
return rindle.wait(step)

View File

@ -61,7 +61,7 @@
"resin-cli-visuals": "^1.3.0",
"resin-config-json": "^1.0.0",
"resin-device-config": "^3.0.0",
"resin-device-init": "^2.1.0",
"resin-device-init": "^2.2.0",
"resin-image-fs": "^2.1.2",
"resin-image-manager": "^4.1.0",
"resin-sdk-preconfigured": "^0.1.1",
@ -75,5 +75,8 @@
"unzip2": "^0.2.5",
"update-notifier": "^0.6.1",
"valid-email": "^0.0.2"
},
"optionalDependencies": {
"removedrive": "^1.0.0"
}
}