mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge master to 0.18
This commit is contained in:
@@ -138,7 +138,7 @@ module.exports = function(RED) {
|
||||
value = value.substring(0,debuglength)+"...";
|
||||
}
|
||||
} else if (value && value.constructor) {
|
||||
if (value.constructor.name === "Buffer") {
|
||||
if (value.type === "Buffer") {
|
||||
value.__encoded__ = true;
|
||||
value.length = value.data.length;
|
||||
if (value.length > debuglength) {
|
||||
|
@@ -75,12 +75,20 @@
|
||||
<dt>payload <span class="property-type">string</span></dt>
|
||||
<dd>the standard output of the command.</dd>
|
||||
</dl>
|
||||
<dl class="message-properties">
|
||||
<dt>rc <span class="property-type">object</span></dt>
|
||||
<dd>exec mode only, a copy of the return code object (also available on port 3)</dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li>Standard error
|
||||
<dl class="message-properties">
|
||||
<dt>payload <span class="property-type">string</span></dt>
|
||||
<dd>the standard error of the command.</dd>
|
||||
</dl>
|
||||
<dl class="message-properties">
|
||||
<dt>rc <span class="property-type">object</span></dt>
|
||||
<dd>exec mode only, a copy of the return code object (also available on port 3)</dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li>Return code
|
||||
<dl class="message-properties">
|
||||
|
@@ -125,14 +125,15 @@ module.exports = function(RED) {
|
||||
if (node.append.trim() !== "") { cl += " "+node.append; }
|
||||
/* istanbul ignore else */
|
||||
if (RED.settings.verbose) { node.log(cl); }
|
||||
child = exec(cl, {encoding: 'binary', maxBuffer:10000000}, function (error, stdout, stderr) {
|
||||
child = exec(cl, {encoding:'binary', maxBuffer:10000000}, function (error, stdout, stderr) {
|
||||
var msg2, msg3;
|
||||
delete msg.payload;
|
||||
if (stderr) {
|
||||
msg2 = RED.util.cloneMessage(msg);
|
||||
msg2.payload = stderr;
|
||||
}
|
||||
msg.payload = Buffer.from(stdout,"binary");
|
||||
if (isUtf8(msg.payload)) { msg.payload = msg.payload.toString(); }
|
||||
var msg2 = null;
|
||||
if (stderr) {
|
||||
msg2 = {payload: stderr};
|
||||
}
|
||||
var msg3 = null;
|
||||
node.status({});
|
||||
//console.log('[exec] stdout: ' + stdout);
|
||||
//console.log('[exec] stderr: ' + stderr);
|
||||
@@ -142,10 +143,15 @@ module.exports = function(RED) {
|
||||
if (error.code === null) { node.status({fill:"red",shape:"dot",text:"killed"}); }
|
||||
else { node.status({fill:"red",shape:"dot",text:"error:"+error.code}); }
|
||||
node.log('error:' + error);
|
||||
} else if (node.oldrc === "false") {
|
||||
}
|
||||
else if (node.oldrc === "false") {
|
||||
msg3 = {payload:{code:0}};
|
||||
}
|
||||
if (!msg3) { node.status({}); }
|
||||
else {
|
||||
msg.rc = msg3.payload;
|
||||
if (msg2) { msg2.rc = msg3.payload; }
|
||||
}
|
||||
node.send([msg,msg2,msg3]);
|
||||
if (child.tout) { clearTimeout(child.tout); }
|
||||
delete node.activeProcesses[child.pid];
|
||||
|
@@ -24,9 +24,10 @@ module.exports = function(RED) {
|
||||
* Custom Mustache Context capable to resolve message property and node
|
||||
* flow and global context
|
||||
*/
|
||||
function NodeContext(msg, nodeContext,parent) {
|
||||
function NodeContext(msg, nodeContext, parent, escapeStrings) {
|
||||
this.msgContext = new mustache.Context(msg,parent);
|
||||
this.nodeContext = nodeContext;
|
||||
this.escapeStrings = escapeStrings;
|
||||
}
|
||||
|
||||
NodeContext.prototype = new mustache.Context();
|
||||
@@ -36,6 +37,14 @@ module.exports = function(RED) {
|
||||
try {
|
||||
var value = this.msgContext.lookup(name);
|
||||
if (value !== undefined) {
|
||||
if (this.escapeStrings && typeof value === "string") {
|
||||
value = value.replace(/\\/g, "\\\\");
|
||||
value = value.replace(/\n/g, "\\n");
|
||||
value = value.replace(/\t/g, "\\t");
|
||||
value = value.replace(/\r/g, "\\r");
|
||||
value = value.replace(/\f/g, "\\f");
|
||||
value = value.replace(/[\b]/g, "\\b");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -75,7 +84,11 @@ module.exports = function(RED) {
|
||||
try {
|
||||
var value;
|
||||
if (node.syntax === "mustache") {
|
||||
value = mustache.render(node.template,new NodeContext(msg, node.context()));
|
||||
if (node.outputFormat === "json") {
|
||||
value = mustache.render(node.template,new NodeContext(msg, node.context(), null, true));
|
||||
} else {
|
||||
value = mustache.render(node.template,new NodeContext(msg, node.context(), null, false));
|
||||
}
|
||||
} else {
|
||||
value = node.template;
|
||||
}
|
||||
|
@@ -102,7 +102,7 @@
|
||||
<dt class="optional">delay <span class="property-type">number</span></dt>
|
||||
<dd>Sets the delay, in milliseconds, to be applied to the message. This
|
||||
option only applies if the node is configured to allow the message to
|
||||
provide the delay interval.</dd>
|
||||
override the configured default delay interval.</dd>
|
||||
<dt class="optional">reset</dt>
|
||||
<dd>If the received message has this property set to any value, all
|
||||
outstanding messages held by the node are cleared without being sent.</dd>
|
||||
@@ -260,7 +260,7 @@
|
||||
$("#delay-details-for").show();
|
||||
$("#random-details").hide();
|
||||
} else if (this.value === "delayv") {
|
||||
$("#delay-details-for").hide();
|
||||
$("#delay-details-for").show();
|
||||
$("#random-details").hide();
|
||||
} else if (this.value === "random") {
|
||||
$("#delay-details-for").hide();
|
||||
|
@@ -105,7 +105,10 @@ module.exports = function(RED) {
|
||||
}
|
||||
else if (node.pauseType === "delayv") {
|
||||
node.on("input", function(msg) {
|
||||
var delayvar = Number(msg.delay || 0);
|
||||
var delayvar = Number(node.timeout);
|
||||
if (msg.hasOwnProperty("delay") && !isNaN(parseFloat(msg.delay))) {
|
||||
delayvar = parseFloat(msg.delay);
|
||||
}
|
||||
if (delayvar < 0) { delayvar = 0; }
|
||||
var id = setTimeout(function() {
|
||||
node.idList.splice(node.idList.indexOf(id),1);
|
||||
@@ -113,7 +116,7 @@ module.exports = function(RED) {
|
||||
node.send(msg);
|
||||
}, delayvar);
|
||||
node.idList.push(id);
|
||||
if ((delayvar >= 1) && (node.idList.length !== 0)) {
|
||||
if ((delayvar >= 0) && (node.idList.length !== 0)) {
|
||||
node.status({fill:"blue",shape:"dot",text:delayvar/1000+"s"});
|
||||
}
|
||||
if (msg.hasOwnProperty("reset")) { clearDelayList(); }
|
||||
|
@@ -92,7 +92,7 @@
|
||||
<p>If set to a <i>string</i> type, the node supports the mustache template syntax.</p>
|
||||
<p>If the node receives a message with a <code>reset</code> property, or a <code>payload</code>
|
||||
that matches that configured in the node, any timeout or repeat currently in
|
||||
progress will be cleared and no message triggered.</o>
|
||||
progress will be cleared and no message triggered.</p>
|
||||
<p>The node can be configured to resend a message at a regular interval until it
|
||||
is reset by a received message.</p>
|
||||
</script>
|
||||
|
@@ -29,6 +29,7 @@ RED.debug = (function() {
|
||||
var messagesByNode = {};
|
||||
var sbc;
|
||||
var activeWorkspace;
|
||||
var numMessages = 100; // Hardcoded number of message to show in debug window scrollback
|
||||
|
||||
var filterVisible = false;
|
||||
|
||||
@@ -369,9 +370,24 @@ RED.debug = (function() {
|
||||
})
|
||||
menuOptionMenu.show();
|
||||
}
|
||||
function handleDebugMessage(o) {
|
||||
var msg = document.createElement("div");
|
||||
|
||||
var stack = [];
|
||||
var busy = false;
|
||||
function handleDebugMessage(o) {
|
||||
if (o) { stack.push(o); }
|
||||
if (!busy && (stack.length > 0)) {
|
||||
busy = true;
|
||||
processDebugMessage(stack.shift());
|
||||
setTimeout(function() {
|
||||
busy = false;
|
||||
handleDebugMessage();
|
||||
}, 15); // every 15mS = 66 times a second
|
||||
if (stack.length > numMessages) { stack = stack.splice(-numMessages); }
|
||||
}
|
||||
}
|
||||
|
||||
function processDebugMessage(o) {
|
||||
var msg = document.createElement("div");
|
||||
var sourceNode = o._source;
|
||||
|
||||
msg.onmouseenter = function() {
|
||||
@@ -497,7 +513,7 @@ RED.debug = (function() {
|
||||
}
|
||||
}
|
||||
|
||||
if (messages.length === 100) {
|
||||
if (messages.length === numMessages) {
|
||||
m = messages.shift();
|
||||
if (view === "list") {
|
||||
m.el.remove();
|
||||
@@ -511,7 +527,6 @@ RED.debug = (function() {
|
||||
return {
|
||||
init: init,
|
||||
refreshMessageList:refreshMessageList,
|
||||
handleDebugMessage: handleDebugMessage,
|
||||
|
||||
handleDebugMessage: handleDebugMessage
|
||||
}
|
||||
})();
|
||||
|
Reference in New Issue
Block a user