summaryrefslogtreecommitdiff
path: root/lib/child_process.js
diff options
context:
space:
mode:
authorTrevor Norris <trev.norris@gmail.com>2014-12-15 19:57:28 -0800
committerTrevor Norris <trev.norris@gmail.com>2014-12-19 16:31:12 -0800
commitae6444dad925a18a66ee0b1db3936534dbf822f4 (patch)
tree8b2fbd96eb6899ebf1f52a0c8c1e3e7a801a2a56 /lib/child_process.js
parent4bba87050c2b8aa801d982e93ea767b3abdc2f17 (diff)
parent813114dab05231b71f3cdc4f5889b9833d9a1d06 (diff)
downloadnode-merge-review2.tar.gz
Merge branch 'v0.10' into merge-review2merge-review2
Reverted caeb6773 for being unable to port the change to deps/v8. The change will be ported directly in a later commit. Conflicts: ChangeLog configure doc/api/child_process.markdown doc/api/tls.markdown doc/api/url.markdown lib/assert.js lib/child_process.js lib/crypto.js lib/dgram.js lib/http.js lib/net.js lib/timers.js lib/tls.js src/node.cc src/node.h src/node.js src/node_crypto.cc src/node_version.h test/common.js test/simple/test-child-process-spawn-typeerror.js tools/certdata.txt
Diffstat (limited to 'lib/child_process.js')
-rw-r--r--lib/child_process.js32
1 files changed, 21 insertions, 11 deletions
diff --git a/lib/child_process.js b/lib/child_process.js
index e18b65435..11a5e9f68 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -560,6 +560,8 @@ exports.fork = function(modulePath /*, args, options*/) {
if (util.isArray(arguments[1])) {
args = arguments[1];
options = util._extend({}, arguments[2]);
+ } else if (arguments[1] && typeof arguments[1] !== 'object') {
+ throw new TypeError('Incorrect value of args option');
} else {
args = [];
options = util._extend({}, arguments[1]);
@@ -645,7 +647,7 @@ exports.exec = function(command /*, options, callback */) {
exports.execFile = function(file /* args, options, callback */) {
- var args, callback;
+ var args = [], optionArg, callback;
var options = {
encoding: 'utf8',
timeout: 0,
@@ -655,18 +657,26 @@ exports.execFile = function(file /* args, options, callback */) {
env: null
};
- // Parse the parameters.
+ // Parse the optional positional parameters.
+ var pos = 1;
+ if (pos < arguments.length && Array.isArray(arguments[pos])) {
+ args = arguments[pos++];
+ } else if (pos < arguments.length && arguments[pos] == null) {
+ pos++;
+ }
- if (util.isFunction(arguments[arguments.length - 1])) {
- callback = arguments[arguments.length - 1];
+ if (pos < arguments.length && typeof arguments[pos] === 'object') {
+ options = util._extend(options, arguments[pos++]);
+ } else if (pos < arguments.length && arguments[pos] == null) {
+ pos++;
}
- if (util.isArray(arguments[1])) {
- args = arguments[1];
- options = util._extend(options, arguments[2]);
- } else {
- args = [];
- options = util._extend(options, arguments[1]);
+ if (pos < arguments.length && typeof arguments[pos] === 'function') {
+ callback = arguments[pos++];
+ }
+
+ if (pos === 1 && arguments.length > 1) {
+ throw new TypeError('Incorrect value of args option');
}
var child = spawn(file, args, {
@@ -970,7 +980,7 @@ function normalizeSpawnArguments(file /*, args, options*/) {
}
-var spawn = exports.spawn = function(/*file, args, options*/) {
+var spawn = exports.spawn = function(file /*, args, options*/) {
var opts = normalizeSpawnArguments.apply(null, arguments);
var options = opts.options;
var child = new ChildProcess();