child-process-async
The best way to override Node's child_process
module w/ Promises
child-process-async
provides a drop-in replacement for the original
child_process
functions, not just duplicate methods that return a Promise.
So when you call exec(...)
we still return a ChildProcess
instance, just
with .then()
and .catch()
added to it to make it promise-friendly.
Install
npm install --save child-process-async
Usage
// OLD:const exec spawn = ;// NEW:const exec spawn = ;
exec()
{ const stdout stderr = await ; // OR: const child = await ; // do whatever you want with `child` here - it's a ChildProcess instance just // with promise-friendly `.then()` & `.catch()` functions added to it! childstdin; childstdout; childstderr; const stdout stderr = await child;}
spawn()
{ const stdout stderr exitCode = await ; // OR: const child = ; // do whatever you want with `child` here - it's a ChildProcess instance just // with promise-friendly `.then()` & `.catch()` functions added to it! childstdin; childstdout; childstderr; const stdout stderr exitCode = await child;}