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) { exports.awaitDevice = function(uuid) {
return resin.models.device.getName(uuid).then(function(deviceName) {
var poll, spinner; var poll, spinner;
spinner = new visuals.Spinner("Waiting for your device to come online: " + uuid); spinner = new visuals.Spinner("Waiting for " + deviceName + " to come online");
poll = function() { poll = function() {
return resin.models.device.isOnline(uuid).then(function(isOnline) { return resin.models.device.isOnline(uuid).then(function(isOnline) {
if (isOnline) { if (isOnline) {
spinner.stop(); spinner.stop();
console.info("Device became online: " + uuid); console.info("Device became online: " + deviceName);
} else { } else {
spinner.start(); spinner.start();
return Promise.delay(3000).then(poll); return Promise.delay(3000).then(poll);
} }
}); });
}; };
return resin.models.device.getName(uuid).then(function(deviceName) {
console.info("Waiting for " + deviceName + " to connect to resin..."); console.info("Waiting for " + deviceName + " to connect to resin...");
return poll()["return"](uuid); return poll()["return"](uuid);
}); });

View File

@ -62,13 +62,14 @@ exports.selectProjectDirectory = ->
default: projectsDirectory default: projectsDirectory
exports.awaitDevice = (uuid) -> exports.awaitDevice = (uuid) ->
spinner = new visuals.Spinner("Waiting for your device to come online: #{uuid}") resin.models.device.getName(uuid).then (deviceName) ->
spinner = new visuals.Spinner("Waiting for #{deviceName} to come online")
poll = -> poll = ->
resin.models.device.isOnline(uuid).then (isOnline) -> resin.models.device.isOnline(uuid).then (isOnline) ->
if isOnline if isOnline
spinner.stop() spinner.stop()
console.info("Device became online: #{uuid}") console.info("Device became online: #{deviceName}")
return return
else else
@ -78,7 +79,6 @@ exports.awaitDevice = (uuid) ->
return Promise.delay(3000).then(poll) return Promise.delay(3000).then(poll)
resin.models.device.getName(uuid).then (deviceName) ->
console.info("Waiting for #{deviceName} to connect to resin...") console.info("Waiting for #{deviceName} to connect to resin...")
poll().return(uuid) poll().return(uuid)