-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
Closed
Labels
child_processIssues and PRs related to the child_process subsystem.Issues and PRs related to the child_process subsystem.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.
Description
- Version: At least from 4.8.0 up to 6.10.0
- Platform: debian 8
- Subsystem: lib/child_process.js
var exec = require('child_process').exec;
var options = {
env : {
NODE_ENV : 'production'
}
};
exec(command, options, function(err, stdout, stderr) {
//do something here
});
The above will loose all other process.env variables.
This might be correct behavior, but on the other hand I personally would have expected that exec does internally something like:
var env;
if (options.env){
env = Object.assign({}, process.env, options.env);
} else {
env = Object.assign({}, process.env);
}
and then using it further on. This makes every child process having the process.env with possibility to override specific env vars. I am not familiar with use cases or what other developers would expect, but at least the above way drops out that logic from customer apps and could feel comfortable.
Suppressing that with options.env = false could be an idea too.
So don't understand this as a reported bug, just an improvement idea you might think about.
Thanks!
Metadata
Metadata
Assignees
Labels
child_processIssues and PRs related to the child_process subsystem.Issues and PRs related to the child_process subsystem.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.