Skip to content

Commit e50d040

Browse files
author
Dave Conway-Jones
committed
Let exec node handle 0 as well as "0"
1 parent b6fcaac commit e50d040

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

nodes/core/core/75-exec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module.exports = function(RED) {
2929
this.useSpawn = n.useSpawn;
3030
this.timer = Number(n.timer || 0)*1000;
3131
this.activeProcesses = {};
32+
var node = this;
3233

3334
var cleanup = function(p) {
3435
//console.log("CLEANUP!!!",p);
@@ -37,16 +38,15 @@ module.exports = function(RED) {
3738
node.error("Exec node timeout");
3839
}
3940

40-
var node = this;
4141
this.on("input", function(msg) {
4242
var child;
4343
node.status({fill:"blue",shape:"dot",text:" "});
4444
if (this.useSpawn === true) {
4545
// make the extra args into an array
4646
// then prepend with the msg.payload
4747
var arg = node.cmd;
48-
if (node.addpay) { arg += " "+msg.payload; }
49-
arg += " "+node.append;
48+
if ((node.addpay === true) && msg.hasOwnProperty("payload")) { arg += " "+msg.payload; }
49+
if (node.append.trim() !== "") { arg += " "+node.append; }
5050
// slice whole line by spaces (trying to honour quotes);
5151
arg = arg.match(/(?:[^\s"]+|"[^"]*")+/g);
5252
var cmd = arg.shift();
@@ -88,7 +88,7 @@ module.exports = function(RED) {
8888
}
8989
else {
9090
var cl = node.cmd;
91-
if ((node.addpay === true) && ((msg.payload || "").toString().trim() !== "")) { cl += " "+msg.payload; }
91+
if ((node.addpay === true) && msg.hasOwnProperty("payload")) { cl += " "+msg.payload; }
9292
if (node.append.trim() !== "") { cl += " "+node.append; }
9393
/* istanbul ignore else */
9494
if (RED.settings.verbose) { node.log(cl); }

0 commit comments

Comments
 (0)