setup.js
This file
Path
lib/pipe/setup.js
60 lines · 2.0 KiB · JavaScript
Last changed by
Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d
History of this fileTake it
Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
line 1why, one step back1import isPlainObject from 'is-plain-obj';Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 2why, one step back2import {normalizePipeArguments} from './validate.js';Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 3why, one step back3import {handlePipeArgumentsError} from './throw.js';Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 4–5why, one step back4import {waitForBothSubprocesses} from './sequence.js';5import {pipeSubprocessStream} from './streaming.js';Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 6–7why, one step back6import {unpipeOnAbort} from './abort.js';7Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 8–9why, one step back8// Pipe a subprocess' `stdout`/`stderr`/`stdio` into another subprocess' `stdin`9export const pipeToSubprocess = (sourceInfo, ...args) => {Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
line 10why, one step back10 if (isPlainObject(args[0])) {Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 11why, one step back11 return pipeToSubprocess.bind(undefined, {Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
line 12why, one step back12 ...sourceInfo,Allow piping process to any file descriptor (#903)ehmickybefore adoption6642cd2
line 13why, one step back13 boundOptions: {...sourceInfo.boundOptions, ...args[0]},Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
lines 14–16why, one step back14 });15 }16Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 17–18why, one step back17 const {destination, ...normalizedInfo} = normalizePipeArguments(sourceInfo, ...args);18 const promise = handlePipePromise({...normalizedInfo, destination});Allow piping process to any file descriptor (#903)ehmickybefore adoption6642cd2
line 19why, one step back19 promise.pipe = pipeToSubprocess.bind(undefined, {...sourceInfo, source: destination, sourcePromise: promise, boundOptions: {}});Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 20–22why, one step back20 return promise;21};22Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 23–30why, one step back23const handlePipePromise = async ({24 sourcePromise,25 sourceStream,26 sourceOptions,27 sourceError,28 destination,29 destinationStream,30 destinationError,Rename `signal` option to `unpipeSignal` (#852)ehmickybefore adoption9dc1141
line 31why, one step back31 unpipeSignal,Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d
line 32why, one step back32 fileDescriptors,Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
line 33why, one step back33 startTime,Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 34why, one step back34}) => {Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 35why, one step back35 const subprocessPromises = getSubprocessPromises(sourcePromise, destination);Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 36–40why, one step back36 handlePipeArgumentsError({37 sourceStream,38 sourceError,39 destinationStream,40 destinationError,Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d
line 41why, one step back41 fileDescriptors,Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 42why, one step back42 sourceOptions,Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
line 43why, one step back43 startTime,Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 44why, one step back44 });Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 45–46why, one step back45 const maxListenersController = new AbortController();46 try {Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 47why, one step back47 const mergedStream = pipeSubprocessStream(sourceStream, destinationStream, maxListenersController);Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 48why, one step back48 return await Promise.race([Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 49why, one step back49 waitForBothSubprocesses(subprocessPromises),Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d
line 50why, one step back50 ...unpipeOnAbort(unpipeSignal, {sourceStream, mergedStream, sourceOptions, fileDescriptors, startTime}),Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 51–54why, one step back51 ]);52 } finally {53 maxListenersController.abort();54 }Improve spawning errors (#847)ehmickybefore adoption381dee2
line 55why, one step back55};Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
line 56why, one step back56Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 57why, one step back57// `.pipe()` awaits the subprocess promises.Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
lines 58–59why, one step back58// When invalid arguments are passed to `.pipe()`, we throw an error, which prevents awaiting them.59// We need to ensure this does not create unhandled rejections.Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 60why, one step back60const getSubprocessPromises = (sourcePromise, destination) => Promise.allSettled([sourcePromise, destination]);