executive
An easy to use wrapper around child_process.spawn
, useful for Cakefiles and the like. Pipes stdout
, stderr
and stdin
so you don't have to. Think of it as a streaming child_process.exec
with a few extra goodies.
Examples
var exec = require('executive');
exec('ls', function(err, out, code) {
});
Also supports simple serial execution of commands:
var exec = require('executive');
exec(['ls', 'ls', 'ls'], function(err, out, code) {
});
Arguments are parsed out properly for you:
var exec = require('executive');
exec('ls -AGF Foo\\ bar', function(err, out, code) {
});
If you'd prefer not to pipe stdin
, stdout
, stderr
:
var exec = require('executive');
exec(['ls', 'ls'], {quiet: true}, function(err, out, code) {
});
...or slightly more succint:
exec.quiet(['ls', 'ls'], function(err, out, code) {
});
In the case of a failure, no additional commands will be executed:
exec(['ls', 'aaaaa', 'ls'], function(err, out, code) {
});
...but you can also choose to ignore errors:
exec(['ls', 'aaaaaa', 'ls'], {safe: false}, function(err, out, code) {
});
If you need to interact with a program, for instance vim, use interactive mode:
exec.interactive('vim', function(err) {
});
You even do whatever you want with the child process object:
var exec = require('executive');
child = exec.quiet('ls');
child.stdout.on('data', function(data) {
console.log(data.toString());
});
It's especially nice to use in a Cakefile:
exec = require 'executive'
task 'package', 'Package project', ->
exec '''
mkdir -p dist
rm -rf dist/*
cp manifest.json dist
cp -rf assets dist
cp -rf lib dist
cp -rf views dist
zip -r package.zip dist
rm -rf dist
'''.split '\n'