nodeproc
Simpler way to handle spawning processes in NodeJs
var Nodeproc = require('nodeproc');
var processes = new Nodeproc();
processes.spawn('npm ls').then(function(results) {
console.log('Finished');
console.log('Process ID: ', results.procId);
console.log('Exit code: ', results.exitCode);
});
processes.spawn({
command: 'npm',
args: ['ls'],
cwd: '/home/joe'
}).then(function() {
console.log('Finished');
});
var captureStdout = {
write: function(data, encoding) {
console.log('Got data: ', data.toString(encoding));
}
};
processes.spawn({
command: 'npm',
args: 'ls'
stdout: captureStdout
}).then(funnction() {
console.log('Finished');
});
processes.spawn({
command: 'npm',
args: ['doesnotexit'],
ignoreExitCode: true
}).catch(function(err) {
console.log('Got error! ', err);
console.log('Process ID: ', err.procId);
console.log('Exit code: ', err.exitCode);
console.log('Stderr: ', err.stderr);
});
processes.spawn({
command: 'npm',
args: ['doesnotexit'],
ignoreExitStatusCode: true
}).then(function() {
console.log('Finished');
});
processes.spawn('npm ls').kill();
var processes2 = new Nodeproc({invalidateOnError = true});
See the tests for more examples