sequence.js
This file
Path
lib/pipe/sequence.js
24 lines · 950 bytes · JavaScript
Last changed by
Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
History of this fileTake it
Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 1–5why, one step back1// Like Bash, we await both subprocesses. This is unlike some other shells which only await the destination subprocess.2// Like Bash with the `pipefail` option, if either subprocess fails, the whole pipe fails.3// Like Bash, if both subprocesses fail, we return the failure of the destination.4// This ensures both subprocesses' errors are present, using `error.pipedFrom`.5export const waitForBothSubprocesses = async subprocessPromises => {Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 6–8why, one step back6 const [7 {status: sourceStatus, reason: sourceReason, value: sourceResult = sourceReason},8 {status: destinationStatus, reason: destinationReason, value: destinationResult = destinationReason},Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 9why, one step back9 ] = await subprocessPromises;Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 10–24why, one step back1011 if (!destinationResult.pipedFrom.includes(sourceResult)) {12 destinationResult.pipedFrom.push(sourceResult);13 }1415 if (destinationStatus === 'rejected') {16 throw destinationResult;17 }1819 if (sourceStatus === 'rejected') {20 throw sourceResult;21 }2223 return destinationResult;24};