summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpepper <pepper@chimecrisis.com>2014-05-06 14:34:43 -0700
committerpepper <pepper@chimecrisis.com>2014-05-06 14:34:43 -0700
commit034c1bbdcc6730f6d185a341f809d89a5fd5fb05 (patch)
treebe29af46a7ee8164d0b1a3bd46d6006322313667
parent5ca92d7e47f7558cc0798051041b687ec9495a93 (diff)
started with bluebird
-rw-r--r--using_bluebird/execute-cmd.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/using_bluebird/execute-cmd.js b/using_bluebird/execute-cmd.js
new file mode 100644
index 0000000..937de62
--- /dev/null
+++ b/using_bluebird/execute-cmd.js
@@ -0,0 +1,23 @@
+var Promise = require("bluebird");
+var childProcess = require("child_process");
+function dumper(content){
+ console.log(JSON.stringify(content));
+}
+function execute(cmd){
+ var promise = Promise.pending();
+ var result = {};
+ var sh = childProcess.exec(cmd, function(error, stdout, stderr){
+ console.log(stdout)
+ result.stdout = stdout;
+ result.stderr = stderr;
+ result.error = error;
+ promise.fulfill(result);
+ });
+// sh.on("exit", function(){
+// console.log(result.stdout)
+// });
+ return promise.promise
+}
+
+execute("echo bitches").then(function(result){ dumper(result) });
+//DO NOT USE sh.on