Skip to content

Commit f57b831

Browse files
committed
do not mutate options
1 parent 91ef0fa commit f57b831

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ module.exports = function(opts) {
88
delete process.env[id];
99
} else {
1010
// In the parent, set the tracking environment variable, fork the child and exit
11-
opts = Object.assign({}, {
11+
opts = opts || {};
12+
const o = Object.assign({
1213
// spawn options
13-
env: process.env,
14+
env: Object.assign(process.env, opts.env, {[id]: "1"}),
1415
cwd: process.cwd(),
1516
stdio: "ignore",
1617
detached: true,
@@ -20,8 +21,7 @@ module.exports = function(opts) {
2021
arguments: process.argv.slice(2),
2122
exitCode: 0,
2223
}, opts);
23-
opts.env = Object.assign({}, opts.env, {[id]: "1"});
24-
require("child_process").spawn(opts.node, [opts.script].concat(opts.arguments), opts).unref();
25-
process.exit(opts.exitCode);
24+
require("child_process").spawn(o.node, [o.script].concat(o.arguments), o).unref();
25+
process.exit(o.exitCode);
2626
}
2727
};

0 commit comments

Comments
 (0)