mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
let daemon node pass old msg properties
This commit is contained in:
parent
f5de5bc707
commit
2070a932be
@ -15,6 +15,7 @@ module.exports = function(RED) {
|
|||||||
this.autorun = true;
|
this.autorun = true;
|
||||||
if (n.autorun === false) { this.autorun = false; }
|
if (n.autorun === false) { this.autorun = false; }
|
||||||
var node = this;
|
var node = this;
|
||||||
|
var lastmsg = {};
|
||||||
|
|
||||||
function inputlistener(msg) {
|
function inputlistener(msg) {
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
@ -34,6 +35,7 @@ module.exports = function(RED) {
|
|||||||
if (RED.settings.verbose) { node.log("inp: "+msg.payload); }
|
if (RED.settings.verbose) { node.log("inp: "+msg.payload); }
|
||||||
if (node.child !== null && node.running) { node.child.stdin.write(msg.payload); }
|
if (node.child !== null && node.running) { node.child.stdin.write(msg.payload); }
|
||||||
else { node.warn("Command not running"); }
|
else { node.warn("Command not running"); }
|
||||||
|
lastmsg = msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,13 +60,15 @@ module.exports = function(RED) {
|
|||||||
line += data.toString();
|
line += data.toString();
|
||||||
var bits = line.split("\n");
|
var bits = line.split("\n");
|
||||||
while (bits.length > 1) {
|
while (bits.length > 1) {
|
||||||
node.send([{payload:bits.shift()},null,null]);
|
lastmsg.payload = bits.shift();
|
||||||
|
node.send([lastmsg,null,null]);
|
||||||
}
|
}
|
||||||
line = bits[0];
|
line = bits[0];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (data && (data.length !== 0)) {
|
if (data && (data.length !== 0)) {
|
||||||
node.send([{payload:data},null,null]);
|
lastmsg.payload = data;
|
||||||
|
node.send([lastmsg,null,null]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -73,7 +77,8 @@ module.exports = function(RED) {
|
|||||||
if (node.op === "string") { data = data.toString(); }
|
if (node.op === "string") { data = data.toString(); }
|
||||||
if (node.op === "number") { data = Number(data); }
|
if (node.op === "number") { data = Number(data); }
|
||||||
if (RED.settings.verbose) { node.log("err: "+data); }
|
if (RED.settings.verbose) { node.log("err: "+data); }
|
||||||
node.send([null,{payload:data},null]);
|
lastmsg.payload = data;
|
||||||
|
node.send([null,lastmsg,null]);
|
||||||
});
|
});
|
||||||
|
|
||||||
node.child.on('close', function (code,signal) {
|
node.child.on('close', function (code,signal) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-daemon",
|
"name" : "node-red-node-daemon",
|
||||||
"version" : "0.0.23",
|
"version" : "0.0.24",
|
||||||
"description" : "A Node-RED node that runs and monitors a long running system command.",
|
"description" : "A Node-RED node that runs and monitors a long running system command.",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user