Show a spinner if no progress state in os download command

This commit is contained in:
Juan Cruz Viotti 2015-03-16 11:45:17 -04:00
parent 5efa7309be
commit fa258a84cc
3 changed files with 24 additions and 7 deletions

View File

@ -66,11 +66,21 @@
}, function(callback) {
return mkdirp(path.dirname(options.output), _.unary(callback));
}, function(callback) {
var bar;
var bar, spinner;
console.info("Destination file: " + options.output + "\n");
bar = new visuals.widgets.Progress('Downloading Device OS');
return resin.models.os.download(osParams, options.output, callback, function(state) {
spinner = new visuals.widgets.Spinner('Downloading Device OS (size unknown)');
return resin.models.os.download(osParams, options.output, function(error) {
spinner.stop();
if (error != null) {
return callback(error);
}
}, function(state) {
if (state != null) {
return bar.update(state);
} else {
return spinner.start();
}
});
}
], function(error) {

View File

@ -76,9 +76,16 @@ exports.download =
console.info("Destination file: #{options.output}\n")
bar = new visuals.widgets.Progress('Downloading Device OS')
spinner = new visuals.widgets.Spinner('Downloading Device OS (size unknown)')
resin.models.os.download osParams, options.output, callback, (state) ->
resin.models.os.download osParams, options.output, (error) ->
spinner.stop()
return callback(error) if error?
, (state) ->
if state?
bar.update(state)
else
spinner.start()
], (error) ->
return done(error) if error?

View File

@ -61,8 +61,8 @@
"npm": "^2.6.1",
"open": "0.0.5",
"progress-stream": "^0.5.0",
"resin-cli-visuals": "^0.0.8",
"resin-sdk": "^0.0.2",
"resin-cli-visuals": "^0.1.0",
"resin-sdk": "^0.0.4",
"resin-vcs": "^1.0.0",
"underscore.string": "~2.4.0",
"update-notifier": "^0.3.1"