brsolab-process
Wrapper for Nodejs Child process library
Uses the ES6 to make it simple the use of subprocess in nodeJS
This library contains two functions: spawn & exec
It's better to use spawn instead of exec when it's possible to avoid args escape problems
Those two functions use the some options as the original ones of nodejs. See the doc page at: https://nodejs.org/api/child_process.html
spawn
exec
examples
const { spawn, exec } = require('brsolab-process');
const fs = require('fs');
exec('ls .').then( result => console.log(result) ).catch( error => console.error(error) );
(async function(){
result = await spawn('command', [args]);
console.log(result);
await spawn('commande', [args], {stdio : ['pipe', fs.openSync('file.txt'), 'pipe']});
var result = await spawn('cmd', [args], {options}, prcess => {
prcess.send({ foo: 'bar', baz: NaN });
});
})();