diff options
| author | pepper <pepper@chimecrisis.com> | 2014-05-06 14:34:43 -0700 |
|---|---|---|
| committer | pepper <pepper@chimecrisis.com> | 2014-05-06 14:34:43 -0700 |
| commit | 034c1bbdcc6730f6d185a341f809d89a5fd5fb05 (patch) | |
| tree | be29af46a7ee8164d0b1a3bd46d6006322313667 /using_bluebird | |
| parent | 5ca92d7e47f7558cc0798051041b687ec9495a93 (diff) | |
started with bluebird
Diffstat (limited to 'using_bluebird')
| -rw-r--r-- | using_bluebird/execute-cmd.js | 23 |
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 |
