Shorten the length of await device message

If the spinner message doesn't fit in your terminal, each spinner
position will be printed in different lines.

We mitigate this by dramatically shortenning the message.
This commit is contained in:
Juan Cruz Viotti 2015-10-07 11:38:59 -04:00
parent 97d9b7816f
commit 3149464c7a
2 changed files with 29 additions and 29 deletions

View File

@ -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);
});

View File

@ -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)