From 22cf5a24dbc76c78acc161eec6c072263003b14e Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Mon, 29 Nov 2010 12:06:15 -0600 Subject: [PATCH] Simplify execution from "big if statement" This code is functionally equivalent, but in a simpler form. Now new parameters to `execFile` do not require `exec` to be refactored. --- lib/child_process.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/child_process.js b/lib/child_process.js index 7dc46289eb4..79fd8e7ffb4 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -12,11 +12,9 @@ var spawn = exports.spawn = function (path, args /*, options OR env, customFds * }; exports.exec = function (command /*, options, callback */) { - if (arguments.length < 3) { - return exports.execFile("/bin/sh", ["-c", command], arguments[1]); - } else { - return exports.execFile("/bin/sh", ["-c", command], arguments[1], arguments[2]); - } + var _slice = Array.prototype.slice; + var args = ["/bin/sh", ["-c", command]].concat(_slice.call(arguments, 1)); + return exports.execFile.apply(this, args) };