mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-04-14 22:46:33 +00:00
Merge pull request #215 from resin-io/jviotti/fix/await-wrap
Shorten the length of await device message
This commit is contained in:
commit
5a3166e3de
@ -96,20 +96,20 @@
|
||||
};
|
||||
|
||||
exports.awaitDevice = function(uuid) {
|
||||
var poll, spinner;
|
||||
spinner = new visuals.Spinner("Waiting for your device to come online: " + uuid);
|
||||
poll = function() {
|
||||
return resin.models.device.isOnline(uuid).then(function(isOnline) {
|
||||
if (isOnline) {
|
||||
spinner.stop();
|
||||
console.info("Device became online: " + uuid);
|
||||
} else {
|
||||
spinner.start();
|
||||
return Promise.delay(3000).then(poll);
|
||||
}
|
||||
});
|
||||
};
|
||||
return resin.models.device.getName(uuid).then(function(deviceName) {
|
||||
var poll, spinner;
|
||||
spinner = new visuals.Spinner("Waiting for " + deviceName + " to come online");
|
||||
poll = function() {
|
||||
return resin.models.device.isOnline(uuid).then(function(isOnline) {
|
||||
if (isOnline) {
|
||||
spinner.stop();
|
||||
console.info("Device became online: " + deviceName);
|
||||
} else {
|
||||
spinner.start();
|
||||
return Promise.delay(3000).then(poll);
|
||||
}
|
||||
});
|
||||
};
|
||||
console.info("Waiting for " + deviceName + " to connect to resin...");
|
||||
return poll()["return"](uuid);
|
||||
});
|
||||
|
@ -62,23 +62,23 @@ exports.selectProjectDirectory = ->
|
||||
default: projectsDirectory
|
||||
|
||||
exports.awaitDevice = (uuid) ->
|
||||
spinner = new visuals.Spinner("Waiting for your device to come online: #{uuid}")
|
||||
|
||||
poll = ->
|
||||
resin.models.device.isOnline(uuid).then (isOnline) ->
|
||||
if isOnline
|
||||
spinner.stop()
|
||||
console.info("Device became online: #{uuid}")
|
||||
return
|
||||
else
|
||||
|
||||
# Spinner implementation is smart enough to
|
||||
# not start again if it was already started
|
||||
spinner.start()
|
||||
|
||||
return Promise.delay(3000).then(poll)
|
||||
|
||||
resin.models.device.getName(uuid).then (deviceName) ->
|
||||
spinner = new visuals.Spinner("Waiting for #{deviceName} to come online")
|
||||
|
||||
poll = ->
|
||||
resin.models.device.isOnline(uuid).then (isOnline) ->
|
||||
if isOnline
|
||||
spinner.stop()
|
||||
console.info("Device became online: #{deviceName}")
|
||||
return
|
||||
else
|
||||
|
||||
# Spinner implementation is smart enough to
|
||||
# not start again if it was already started
|
||||
spinner.start()
|
||||
|
||||
return Promise.delay(3000).then(poll)
|
||||
|
||||
console.info("Waiting for #{deviceName} to connect to resin...")
|
||||
poll().return(uuid)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user