diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2010-02-19 16:55:46 -0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-02-19 16:55:46 -0800 |
commit | de7016eac5653cf101dd4b9aa935f1164ad7941f (patch) | |
tree | 0b7d79e2769f5311ac40f6aa3046fd2f793b92b5 /lib/sys.js | |
parent | c04b679e12c0c09cd78e4dd06e53a90a08986105 (diff) | |
download | android-node-v8-de7016eac5653cf101dd4b9aa935f1164ad7941f.tar.gz android-node-v8-de7016eac5653cf101dd4b9aa935f1164ad7941f.tar.bz2 android-node-v8-de7016eac5653cf101dd4b9aa935f1164ad7941f.zip |
sys.exec() no longer uses Promise
Diffstat (limited to 'lib/sys.js')
-rw-r--r-- | lib/sys.js | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/sys.js b/lib/sys.js index 65badcdc05..cbdf0c5788 100644 --- a/lib/sys.js +++ b/lib/sys.js @@ -138,11 +138,10 @@ exports.p = function () { } }; -exports.exec = function (command) { +exports.exec = function (command, callback) { var child = process.createChildProcess("/bin/sh", ["-c", command]); var stdout = ""; var stderr = ""; - var promise = new events.Promise(); child.addListener("output", function (chunk) { if (chunk) stdout += chunk; @@ -154,13 +153,13 @@ exports.exec = function (command) { child.addListener("exit", function (code) { if (code == 0) { - promise.emitSuccess(stdout, stderr); + if (callback) callback(null, stdout, stderr); } else { - promise.emitError(code, stdout, stderr); + var e = new Error("Command failed: " + stderr); + e.code = code; + if (callback) callback(e, stdout, stderr); } }); - - return promise; }; /** |