Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
child_process: make copy of options arg
Make a copy of the options object that the user passes in, we modify it.
  • Loading branch information
bnoordhuis committed May 10, 2012
1 parent 928d28a commit 68f63fe
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/child_process.js
Expand Up @@ -172,10 +172,10 @@ exports.fork = function(modulePath /*, args, options*/) {
var options, args, execArgv;
if (Array.isArray(arguments[1])) {
args = arguments[1];
options = arguments[2] || {};
options = util._extend({}, arguments[2]);
} else {
args = [];
options = arguments[1] || {};
options = util._extend({}, arguments[1]);
}

// Prepare arguments for fork:
Expand Down Expand Up @@ -264,15 +264,12 @@ exports.execFile = function(file /* args, options, callback */) {

if (Array.isArray(arguments[1])) {
args = arguments[1];
if (typeof arguments[2] === 'object') optionArg = arguments[2];
options = util._extend(options, arguments[2]);
} else {
args = [];
if (typeof arguments[1] === 'object') optionArg = arguments[1];
options = util._extend(options, arguments[1]);
}

// Merge optionArg into options
util._extend(options, optionArg);

var child = spawn(file, args, {
cwd: options.cwd,
env: options.env,
Expand Down

0 comments on commit 68f63fe

Please sign in to comment.