From 91ab3bd972c3f34bf31761bbd8da61c4efdf1339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathana=C3=ABl=20L=C3=A9caud=C3=A9?= Date: Wed, 16 Jun 2021 17:00:00 -0400 Subject: [PATCH] exec node: add windowsHide option to hide windows under Windows --- .../@node-red/nodes/core/function/90-exec.html | 11 +++++++++++ .../@node-red/nodes/core/function/90-exec.js | 3 ++- .../nodes/locales/en-US/function/90-exec.html | 1 + .../@node-red/nodes/locales/en-US/messages.json | 3 ++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/@node-red/nodes/core/function/90-exec.html b/packages/node_modules/@node-red/nodes/core/function/90-exec.html index c4d841a13..9f026448c 100644 --- a/packages/node_modules/@node-red/nodes/core/function/90-exec.html +++ b/packages/node_modules/@node-red/nodes/core/function/90-exec.html @@ -40,6 +40,10 @@ +
+ + +
@@ -56,6 +60,7 @@ append: {value:""}, useSpawn: {value:"false"}, timer: {value:""}, + windowsHide: {value:false}, oldrc: {value:false}, name: {value:""} }, @@ -92,6 +97,12 @@ }); $("#node-input-addpay-cb").trigger("change") + + if (this.windowsHide === "true" || this.windowsHide === true) { + $("#node-input-windowsHide").prop("checked",true); + } else { + $("#node-input-windowsHide").prop("checked",false); + } }, oneditsave: function() { if (!$("#node-input-addpay-cb").prop("checked")) { diff --git a/packages/node_modules/@node-red/nodes/core/function/90-exec.js b/packages/node_modules/@node-red/nodes/core/function/90-exec.js index 9ec60f4ff..7b51d3305 100644 --- a/packages/node_modules/@node-red/nodes/core/function/90-exec.js +++ b/packages/node_modules/@node-red/nodes/core/function/90-exec.js @@ -34,7 +34,8 @@ module.exports = function(RED) { this.timer = Number(n.timer || 0)*1000; this.activeProcesses = {}; this.oldrc = (n.oldrc || false).toString(); - this.execOpt = {encoding:'binary', maxBuffer:RED.settings.execMaxBufferSize||10000000}; + this.execOpt = {encoding:'binary', maxBuffer:RED.settings.execMaxBufferSize||10000000, windowsHide: (n.windowsHide === true)}; + this.spawnOpt = {windowsHide: (n.windowsHide === true) } var node = this; if (process.platform === 'linux' && fs.existsSync('/bin/bash')) { node.execOpt.shell = '/bin/bash'; } diff --git a/packages/node_modules/@node-red/nodes/locales/en-US/function/90-exec.html b/packages/node_modules/@node-red/nodes/locales/en-US/function/90-exec.html index ff515e781..093b3f7ce 100644 --- a/packages/node_modules/@node-red/nodes/locales/en-US/function/90-exec.html +++ b/packages/node_modules/@node-red/nodes/locales/en-US/function/90-exec.html @@ -80,4 +80,5 @@

If the node has more than one process running then msg.pid must also be set with the value of the PID to be killed.

If a value is provided in the Timeout field then, if the process has not completed when the specified number of seconds has elapsed, the process will be killed automatically

Tip: if running a Python app you may need to use the -u parameter to stop the output being buffered.

+

The Hide windows option can be set to hide shell windows under Windows.

diff --git a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json index e5108710b..d559ad712 100755 --- a/packages/node_modules/@node-red/nodes/locales/en-US/messages.json +++ b/packages/node_modules/@node-red/nodes/locales/en-US/messages.json @@ -198,7 +198,8 @@ "seconds": "seconds", "stdout": "stdout", "stderr": "stderr", - "retcode": "return code" + "retcode": "return code", + "windowshide": "Hide windows" }, "placeholder": { "extraparams": "extra input parameters"