1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Let exec node handle 0 as well as "0"

This commit is contained in:
Dave Conway-Jones 2016-06-20 19:28:59 +01:00
parent b6fcaacb77
commit e50d04077b

View File

@ -29,6 +29,7 @@ module.exports = function(RED) {
this.useSpawn = n.useSpawn;
this.timer = Number(n.timer || 0)*1000;
this.activeProcesses = {};
var node = this;
var cleanup = function(p) {
//console.log("CLEANUP!!!",p);
@ -37,7 +38,6 @@ module.exports = function(RED) {
node.error("Exec node timeout");
}
var node = this;
this.on("input", function(msg) {
var child;
node.status({fill:"blue",shape:"dot",text:" "});
@ -45,8 +45,8 @@ module.exports = function(RED) {
// make the extra args into an array
// then prepend with the msg.payload
var arg = node.cmd;
if (node.addpay) { arg += " "+msg.payload; }
arg += " "+node.append;
if ((node.addpay === true) && msg.hasOwnProperty("payload")) { arg += " "+msg.payload; }
if (node.append.trim() !== "") { arg += " "+node.append; }
// slice whole line by spaces (trying to honour quotes);
arg = arg.match(/(?:[^\s"]+|"[^"]*")+/g);
var cmd = arg.shift();
@ -88,7 +88,7 @@ module.exports = function(RED) {
}
else {
var cl = node.cmd;
if ((node.addpay === true) && ((msg.payload || "").toString().trim() !== "")) { cl += " "+msg.payload; }
if ((node.addpay === true) && msg.hasOwnProperty("payload")) { cl += " "+msg.payload; }
if (node.append.trim() !== "") { cl += " "+node.append; }
/* istanbul ignore else */
if (RED.settings.verbose) { node.log(cl); }