I am in the process of porting a CLI library from Ruby over to Node.js. In my code I execute several third party binaries when necessary. I am not sure how best to accomplis
You can use execa.
For example, as a promise:
const execa = require('execa')
execa('cat *.js bad_file').then(
(childProcessResult) => {
//onFulfilled
console.log('Success!', childProcessResult)
},
(childProcessResult) => {
//onRejected
console.log('Error!', childProcessResult)
}
)
Execa improves child_process
methods with:
stdout.trim()
.