Exec node - Allow adding variables to the process environment

I've been using environment variables to store credentials in flows and groups and would like to easily pass them to a executed process without exposing them on the command line. Adding them to the process environment let me accomplish this.

Editing 90-exec.js I've naively inserted the following after line 143[1]
if (typeof msg?.env == "object") node.execOpt.env = msg.env;

and after line 93[2]
if (typeof msg?.env == "object") opts.env = msg.env;

to accomplish this. I'm not a developer but would be interested in adding this to the core node if the maintainers will take a PR. Currently this code naively changes the default behavior of the exec node so I may add an additional setting in the node configuration GUI to disable this behavior or select a different message object. If that would make merging this feature more feasible I am willing to add to the GUI.

Thanks for your consideration,
Nathan

[1] node-red/packages/node_modules/@node-red/nodes/core/function/90-exec.js at a2430b772bd0800d3ebaf4fbe1396ca1fd5f23d6 · node-red/node-red · GitHub

[2] node-red/packages/node_modules/@node-red/nodes/core/function/90-exec.js at a2430b772bd0800d3ebaf4fbe1396ca1fd5f23d6 · node-red/node-red · GitHub

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.