From 4efe27bbabc1e6c6982303c8862f314d6b943dc4 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 14 Apr 2010 18:50:41 -0700 Subject: [PATCH] Add execFile() for Orlando Undocumented for now, but basically like exec() with args. --- lib/child_process.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/child_process.js b/lib/child_process.js index 8066c0fa31..f34a8f47b9 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -10,8 +10,15 @@ var spawn = exports.spawn = function (path, args, env) { return child; }; +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]); + } +}; -exports.exec = function (command /* , options, callback */) { +exports.execFile = function (file, args /*, options, callback */) { var options = { encoding: 'utf8' , timeout: 0 , maxBuffer: 200*1024 @@ -19,15 +26,16 @@ exports.exec = function (command /* , options, callback */) { }; var callback = arguments[arguments.length-1]; - if (typeof arguments[1] == 'object') { + + if (typeof arguments[2] == 'object') { var keys = Object.keys(options); for (var i = 0; i < keys.length; i++) { var k = keys[i]; - if (arguments[1][k] !== undefined) options[k] = arguments[1][k]; + if (arguments[2][k] !== undefined) options[k] = arguments[2][k]; } } - var child = spawn("/bin/sh", ["-c", command]); + var child = spawn(file, args); var stdout = ""; var stderr = ""; var killed = false;