diff options
Diffstat (limited to 'using_Q/ls-test.js')
| -rw-r--r-- | using_Q/ls-test.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/using_Q/ls-test.js b/using_Q/ls-test.js new file mode 100644 index 0000000..c90143d --- /dev/null +++ b/using_Q/ls-test.js @@ -0,0 +1,28 @@ +#!/usr/local/bin/node +Q = require('q'); +var childProcess = require('child_process'), + ls; + + +function get_the_async_data() { + var deferred = Q.defer(); + + ls = childProcess.exec('ls -l', function (error, stdout, stderr) { + if (error) { +// console.log(error.stack); +// console.log('Error code: '+error.code); +// console.log('Signal received: '+error.signal); + } +// console.log('Child Process STDOUT: '+stdout); +// console.log('Child Process STDERR: '+stderr); + }); + + ls.on('exit', function (code) { +// console.log('Child process exited with exit code '+code); + deferred.resolve(code); + }); + + return deferred.promise; +} +get_the_async_data().then(function(code) { console.log(code) } ); +//result should be '0', success! |
