diff options
Diffstat (limited to 'lib/sys.js')
-rw-r--r-- | lib/sys.js | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/lib/sys.js b/lib/sys.js index aef80530e..c3b5d6130 100644 --- a/lib/sys.js +++ b/lib/sys.js @@ -16,7 +16,7 @@ exports.debug = function (x) { process.binding('stdio').writeError("DEBUG: " + x + "\n"); }; -exports.error = function (x) { +var error = exports.error = function (x) { for (var i = 0, len = arguments.length; i < len; ++i) { process.binding('stdio').writeError(arguments[i] + '\n'); } @@ -184,7 +184,7 @@ exports.inspect = function (obj, showHidden, depth) { exports.p = function () { for (var i = 0, len = arguments.length; i < len; ++i) { - exports.error(exports.inspect(arguments[i])); + error(exports.inspect(arguments[i])); } }; @@ -207,29 +207,14 @@ exports.log = function (msg) { exports.puts(timestamp() + ' - ' + msg.toString()); } -exports.exec = function (command, callback) { - var child = process.createChildProcess("/bin/sh", ["-c", command]); - var stdout = ""; - var stderr = ""; - - child.addListener("output", function (chunk) { - if (chunk) stdout += chunk; - }); - - child.addListener("error", function (chunk) { - if (chunk) stderr += chunk; - }); - - child.addListener("exit", function (code) { - if (code == 0) { - if (callback) callback(null, stdout, stderr); - } else { - var e = new Error("Command failed: " + stderr); - e.code = code; - if (callback) callback(e, stdout, stderr); - } - }); -}; +var execWarning; +exports.exec = function () { + if (!execWarning) { + execWarning = 'sys.exec has moved to the "child_process" module. Please update your source code.' + error(execWarning); + } + return require('child_process').exec.apply(this, arguments); +} /** * Inherit the prototype methods from one constructor into another. |