mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
tidy up jsHint errors in exec and trigger nodes
Add "use strict" to the sample node
This commit is contained in:
parent
52779ac518
commit
c7f0f9639a
@ -20,6 +20,7 @@
|
||||
|
||||
|
||||
module.export = function(RED) {
|
||||
"use strict";
|
||||
|
||||
// The main node definition - most things happen in here
|
||||
function SampleNode(n) {
|
||||
|
@ -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({});
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user