Merge pull request #154 from resin-io/jviotti/fix/device-await

Fix broken device await command
This commit is contained in:
Juan Cruz Viotti 2015-08-14 14:31:00 -04:00
commit 30f6a78282
2 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,7 @@
(function() {
var _, async, capitano, commandOptions, deviceConfig, form, htmlToText, image, inject, manager, pine, registerDevice, resin, vcs, visuals;
var Promise, _, async, capitano, commandOptions, deviceConfig, form, htmlToText, image, inject, manager, pine, registerDevice, resin, vcs, visuals;
Promise = require('bluebird');
capitano = require('capitano');
@ -159,18 +161,17 @@
if (options.interval == null) {
options.interval = 3000;
}
return poll = function() {
poll = function() {
return resin.models.device.isOnline(params.uuid).then(function(isOnline) {
if (isOnline) {
console.info("Device became online: " + params.uuid);
return;
} else {
console.info("Polling device network status: " + params.uuid);
return Promise.delay(options.interval).then(poll);
}
return poll().nodeify(done);
});
};
return poll().nodeify(done);
}
};

View File

@ -1,3 +1,4 @@
Promise = require('bluebird')
capitano = require('capitano')
_ = require('lodash')
async = require('async')
@ -221,7 +222,7 @@ exports.await =
else
console.info("Polling device network status: #{params.uuid}")
return Promise.delay(options.interval).then(poll)
poll().nodeify(done)
poll().nodeify(done)
exports.init =
signature: 'device init [device]'