mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-31 00:24:15 +00:00
Implement a spinner when awaiting for a device. Fix #107
Fixes: - https://github.com/resin-io/resin-cli/issues/107
This commit is contained in:
parent
30f6a78282
commit
30f24333c0
@ -157,16 +157,18 @@
|
||||
],
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
var poll;
|
||||
var poll, spinner;
|
||||
if (options.interval == null) {
|
||||
options.interval = 3000;
|
||||
}
|
||||
spinner = new visuals.Spinner("Awaiting device: " + params.uuid);
|
||||
poll = function() {
|
||||
return resin.models.device.isOnline(params.uuid).then(function(isOnline) {
|
||||
if (isOnline) {
|
||||
spinner.stop();
|
||||
console.info("Device became online: " + params.uuid);
|
||||
} else {
|
||||
console.info("Polling device network status: " + params.uuid);
|
||||
spinner.start();
|
||||
return Promise.delay(options.interval).then(poll);
|
||||
}
|
||||
});
|
||||
|
@ -214,13 +214,20 @@ exports.await =
|
||||
action: (params, options, done) ->
|
||||
options.interval ?= 3000
|
||||
|
||||
spinner = new visuals.Spinner("Awaiting device: #{params.uuid}")
|
||||
|
||||
poll = ->
|
||||
resin.models.device.isOnline(params.uuid).then (isOnline) ->
|
||||
if isOnline
|
||||
spinner.stop()
|
||||
console.info("Device became online: #{params.uuid}")
|
||||
return
|
||||
else
|
||||
console.info("Polling device network status: #{params.uuid}")
|
||||
|
||||
# Spinner implementation is smart enough to
|
||||
# not start again if it was already started
|
||||
spinner.start()
|
||||
|
||||
return Promise.delay(options.interval).then(poll)
|
||||
poll().nodeify(done)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user