Handle users of old Blinkstick npm a bit more nicely.

Don't  barf (quite so badly) on new API calls if they don't exist yet.
This commit is contained in:
Dave C-J
2014-11-20 08:44:05 +00:00
parent 74a470c22e
commit 317aaa1b64
3 changed files with 13 additions and 7 deletions

View File

@@ -165,7 +165,14 @@ module.exports = function(RED) {
node.led.setColor(node.color, blinkstickAnimationComplete);
}
} catch (err) {
node.warn("BlinkStick missing ? " + err);
if (err.toString().indexOf("setColor") !== -1) {
node.led.setColour(node.color, blinkstickAnimationComplete);
node.warn("Old version - please upgrade Blinkstick npm");
}
else {
node.warn("BlinkStick missing ? " + err);
}
console.log(err);
//Reset animation
animationComplete = true;
//Clear color
@@ -233,7 +240,8 @@ module.exports = function(RED) {
if (Object.size(node.led) !== 0) {
//Close device and stop animations
this.led.close();
if (typeof this.led.close === "function") { this.led.close(); }
else { node.warn("Please upgrade blinkstick npm"); }
}
});
}