From c7f0f9639a8ea76b9892a04833902aecdaaec307 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Mon, 30 Jun 2014 20:44:35 +0100 Subject: [PATCH] tidy up jsHint errors in exec and trigger nodes Add "use strict" to the sample node --- nodes/99-sample.js.demo | 1 + nodes/core/core/75-exec.js | 7 ++++--- nodes/core/core/89-trigger.js | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/nodes/99-sample.js.demo b/nodes/99-sample.js.demo index efda25a70..078f373a4 100644 --- a/nodes/99-sample.js.demo +++ b/nodes/99-sample.js.demo @@ -20,6 +20,7 @@ module.export = function(RED) { + "use strict"; // The main node definition - most things happen in here function SampleNode(n) { diff --git a/nodes/core/core/75-exec.js b/nodes/core/core/75-exec.js index 4698b22a4..a12baf40e 100644 --- a/nodes/core/core/75-exec.js +++ b/nodes/core/core/75-exec.js @@ -29,13 +29,13 @@ module.exports = function(RED) { this.on("input", function(msg) { if (msg != null) { node.status({fill:"blue",shape:"dot"}); - if (this.useSpawn == true) { + if (this.useSpawn === true) { // make the extra args into an array // then prepend with the msg.payload if (typeof(msg.payload !== "string")) { msg.payload = msg.payload.toString(); } var arg = []; if (node.append.length > 0) { arg = node.append.split(","); } - if (msg.payload.trim() != "") { arg.unshift(msg.payload); } + if (msg.payload.trim() !== "") { arg.unshift(msg.payload); } node.log(node.cmd+" ["+arg+"]"); if (node.cmd.indexOf(" ") == -1) { var ex = spawn(node.cmd,arg); @@ -65,10 +65,11 @@ module.exports = function(RED) { var child = exec(cl, function (error, stdout, stderr) { msg.payload = stdout; var msg2 = {payload:stderr}; + var msg3 = null; //console.log('[exec] stdout: ' + stdout); //console.log('[exec] stderr: ' + stderr); if (error !== null) { - var msg3 = {payload:error}; + msg3 = {payload:error}; //console.log('[exec] error: ' + error); } node.status({}); diff --git a/nodes/core/core/89-trigger.js b/nodes/core/core/89-trigger.js index a3e9e65bd..d86a21309 100644 --- a/nodes/core/core/89-trigger.js +++ b/nodes/core/core/89-trigger.js @@ -28,9 +28,9 @@ module.exports = function(RED) { this.duration = n.duration || 250; if (this.duration <= 0) { this.duration = 0; } else { - if (this.units == "s") this.duration = this.duration * 1000; - if (this.units == "min") this.duration = this.duration * 1000 * 60; - if (this.units == "hr") this.duration = this.duration * 1000 *60 * 60; + if (this.units == "s") { this.duration = this.duration * 1000; } + if (this.units == "min") { this.duration = this.duration * 1000 * 60; } + if (this.units == "hr") { this.duration = this.duration * 1000 *60 * 60; } } this.op1Templated = this.op1.indexOf("{{") != -1; this.op2Templated = this.op2.indexOf("{{") != -1; @@ -64,7 +64,7 @@ module.exports = function(RED) { else if (node.op1Templated) { msg.payload = mustache.render(node.op1,msg); } else { msg.payload = node.op1; } if (node.op1type !== "nul") { node.send(msg); } - if (node.duration == 0) { tout = "infinite"; } + if (node.duration === 0) { tout = "infinite"; } else { tout = setTimeout(function() { msg.payload = m2;