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.
This commit is contained in:
Travis Swicegood 2010-11-29 12:06:15 -06:00 committed by Ryan Dahl
parent e514f575f3
commit 22cf5a24db

View File

@ -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)
};