setup.js
This file
Path
lib/pipe/setup.js
31 lines · 1.3 KiB · JavaScript
Last changed by
Fix failure of series of `.pipe()` (#849)ehmickybefore adoption45744fa
History of this fileTake it
Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 1–8why, one step back1import {normalizePipeArguments} from './validate.js';2import {waitForBothProcesses} from './sequence.js';3import {pipeProcessStream} from './streaming.js';4import {unpipeOnAbort} from './abort.js';56// Pipe a process' `stdout`/`stderr`/`stdio` into another process' `stdin`7export const pipeToProcess = (sourceInfo, destination, pipeOptions) => {8 const promise = handlePipePromise(sourceInfo, destination, pipeOptions);Fix failure of series of `.pipe()` (#849)ehmickybefore adoption45744fa
line 9why, one step back9 promise.pipe = pipeToProcess.bind(undefined, {...sourceInfo, source: destination, sourcePromise: promise});Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 10–13why, one step back10 return promise;11};1213const handlePipePromise = async (sourceInfo, destination, {from, signal} = {}) => {Fix failure of series of `.pipe()` (#849)ehmickybefore adoption45744fa
line 14why, one step back14 const {sourcePromise, sourceStream, destinationStream} = normalizePipeArguments(destination, from, sourceInfo);Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 15–18why, one step back15 const maxListenersController = new AbortController();16 try {17 const mergedStream = pipeProcessStream(sourceStream, destinationStream, maxListenersController);18 return await Promise.race([Fix failure of series of `.pipe()` (#849)ehmickybefore adoption45744fa
line 19why, one step back19 waitForBothProcesses(sourcePromise, destination),Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 20–25why, one step back20 ...unpipeOnAbort(signal, sourceStream, mergedStream, sourceInfo),21 ]);22 } finally {23 maxListenersController.abort();24 }25};Improve spawning errors (#847)ehmickybefore adoption381dee2
lines 26–31why, one step back2627export const dummyPipeToProcess = (source, destination) => {28 const promise = Promise.all([source, destination]);29 promise.pipe = dummyPipeToProcess.bind(undefined, promise);30 return promise;31};