ShellJS - Unix Shell Commands for Node.js Build Status
ShellJS is a portable (Windows / Linux / OS X) implementation of Unix shell commands on top of the Node.js API. You can use it to eliminate your Unix-dependent script shell while maintaining your familiar and powerful commands. You can also install it globally so you can run it from outside Node projects - say goodbye to those gnarly Bash scripts!
exec (command [, options] [, callback])
Available options (all false by default):
async: Asynchronous execution. Defaults to true if a callback is provided. silent: Do not echo program output to console.
Examples:
var version = exec ('node --version', {silent: true}). output;
var child = exec ('some_long_running_process', {async: true}); child.stdout.on ('data', function (data) {/ * ... do something with the data ... * /});
exec ('some_long_running_process', function (code, output) {
console.log ('Exit code:', code); console.log ('Program output:', output); });
Executes this command synchronously, unless otherwise specified. When the object {code: ..., output: ...} containing the program output (stdout + stderr) and the exit code is returned in synchronous mode. Otherwise, it returns a child of the process, and the callback receives arguments (code, output).
Note. For long-running processes, it is best to run exec () asynchronously since the current synchronous implementation uses a lot of CPU. This should be fixed soon.