README
Remover
Flexible spawn() with exec() syntax.
Install
npm install spawnx
API
spawnx(command, [options,] callback);
Usage
var run = require('spawnx');
run('/path/to/command --foo bar 1', function(err, stdout, stderr) {
console.log(err || stdout);
})
// let's pipe the output from the command to a log file as it comes.
var stream = fs.createWriteStream('output.log');
run('another_command --test', { cwd: '/tmp', stdout: stream }, function(err) {
console.log('Finished');
stream.close();
})
Options
Whatever options you pass in the options argument will be passed to the actual
spawn()
call. There are two additional options that you may pass: stdout
and
stderr
. If present, spawnx will pipe the output from the spawn
command to
those streams. That way you can have live output of a running command.
Also important: the path to command may be relative, in which case the full
path is looked for by searching the environment's $PATH
. If now options.cwd
is
set, the command's dirname is set as the cwd
for the spawn call.
Credits
Written by Tomás Pollak.
Copyright
(c) Fork Ltd. MIT license.