summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Roberts <sam@strongloop.com>2014-01-15 17:16:22 -0800
committerTimothy J Fontaine <tjfontaine@gmail.com>2014-01-16 07:35:12 -0800
commit67e9298fb6509d5f6ad2f7e67620a2d82549a1e8 (patch)
tree63867e3f2e18c81705bf31293e6896baed8aea43
parent198ed0bd0da9dee471bb8bfb7f6e97be506224ed (diff)
downloadnode-67e9298fb6509d5f6ad2f7e67620a2d82549a1e8.tar.gz
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.
-rw-r--r--lib/child_process.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/child_process.js b/lib/child_process.js
index f7312215c..eec031333 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -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;