({subprocess, concurrentStreams}, {to} = {})
| 12 | |
| 13 | // Create a `Writable` stream that forwards to `stdin` and awaits the subprocess |
| 14 | export const createWritable = ({subprocess, concurrentStreams}, {to} = {}) => { |
| 15 | const {subprocessStdin, waitWritableFinal, waitWritableDestroy} = getSubprocessStdin(subprocess, to, concurrentStreams); |
| 16 | const writable = new Writable({ |
| 17 | ...getWritableMethods(subprocessStdin, subprocess, waitWritableFinal), |
| 18 | destroy: callbackify(onWritableDestroy.bind(undefined, { |
| 19 | subprocessStdin, |
| 20 | subprocess, |
| 21 | waitWritableFinal, |
| 22 | waitWritableDestroy, |
| 23 | })), |
| 24 | highWaterMark: subprocessStdin.writableHighWaterMark, |
| 25 | objectMode: subprocessStdin.writableObjectMode, |
| 26 | }); |
| 27 | onStdinFinished(subprocessStdin, writable, undefined, subprocess); |
| 28 | return writable; |
| 29 | }; |
| 30 | |
| 31 | // Retrieve `stdin` (or other stream depending on `to`) |
| 32 | export const getSubprocessStdin = (subprocess, to, concurrentStreams) => { |
nothing calls this directly
no test coverage detected