Browse Source

child_process: fix spawn() optional arguments

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.
v0.10.25-release
Sam Roberts 11 years ago
committed by Timothy J Fontaine
parent
commit
67e9298fb6
  1. 12
      lib/child_process.js

12
lib/child_process.js

@ -695,8 +695,16 @@ exports.execFile = function(file /* args, options, callback */) {
}; };
var spawn = exports.spawn = function(file, args, options) { var spawn = exports.spawn = function(file /*, args, options*/) {
args = args ? args.slice(0) : []; var args, options;
if (Array.isArray(arguments[1])) {
args = arguments[1].slice(0);
options = arguments[2];
} else {
args = [];
options = arguments[1];
}
args.unshift(file); args.unshift(file);
var env = (options ? options.env : null) || process.env; var env = (options ? options.env : null) || process.env;

Loading…
Cancel
Save