Skip to content

Commit

Permalink
child_process: fix spawn() optional arguments
Browse files Browse the repository at this point in the history
Spawn's arguments were documented to be optional, as they are for the
other similar child_process APIs, but the code was missing. Result was
`child_process.spawn('node', {})` errored when calling slice() on an
Object, now it behaves as the documentation said it would.
  • Loading branch information
sam-github authored and tjfontaine committed Jan 16, 2014
1 parent 198ed0b commit 67e9298
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,16 @@ exports.execFile = function(file /* args, options, callback */) {
};


var spawn = exports.spawn = function(file, args, options) {
args = args ? args.slice(0) : [];
var spawn = exports.spawn = function(file /*, args, options*/) {
var args, options;
if (Array.isArray(arguments[1])) {
args = arguments[1].slice(0);
options = arguments[2];
} else {
args = [];
options = arguments[1];
}

args.unshift(file);

var env = (options ? options.env : null) || process.env;
Expand Down

0 comments on commit 67e9298

Please sign in to comment.