spawn a subprocess to read from it
spawn a subprocess for reading from.
npm i spawn-read-stream
Returns a promise for a stream.
child_process.spawn to spawn the process, and once its standard output becomes readable, hands it over.
If the process fails before becoming readable, the promise is rejected with an error.
If the process fails after becoming readable, an error is emitted on the stream.
For clarity, command is allowed to be an array, for cases like
zfs send, where
zfs clearly isn't a very useful description of what command is being run.
This only makes a difference for error reporting.
exit event is re-emitted on the stream, after any error events.
then, depending on how it exited:
'`' + command + '` killed by signal `' + err.signal + '`'
'`' command + '` exited with ' + err.code