stdio.js
This file
Path
lib/resolve/stdio.js
48 lines · 1.3 KiB · JavaScript
Last changed by
Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f
History of this fileTake it
The walk stopped after 200 commits: lines older than 9f65b86 point at it.
100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 1–18why, one step back1import {getStreamOutput} from '../io/contents.js';2import {waitForStream, isInputFileDescriptor} from './wait-stream.js';34// Read the contents of `subprocess.std*` and|or wait for its completion5export const waitForStdioStreams = ({subprocess, encoding, buffer, maxBuffer, lines, stripFinalNewline, verboseInfo, streamInfo}) => subprocess.stdio.map((stream, fdNumber) => waitForSubprocessStream({6 stream,7 fdNumber,8 encoding,9 buffer: buffer[fdNumber],10 maxBuffer: maxBuffer[fdNumber],11 lines: lines[fdNumber],12 allMixed: false,13 stripFinalNewline,14 verboseInfo,15 streamInfo,16}));1718// Read the contents of `subprocess.std*` or `subprocess.all` and|or wait for its completionFix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f
line 19why, one step back19export const waitForSubprocessStream = async ({stream, fdNumber, encoding, buffer, maxBuffer, lines, allMixed, stripFinalNewline, allFds, verboseInfo, streamInfo}) => {100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 20–40why, one step back20 if (!stream) {21 return;22 }2324 const onStreamEnd = waitForStream(stream, fdNumber, streamInfo);25 if (isInputFileDescriptor(streamInfo, fdNumber)) {26 await onStreamEnd;27 return;28 }2930 const [output] = await Promise.all([31 getStreamOutput({32 stream,33 onStreamEnd,34 fdNumber,35 encoding,36 buffer,37 maxBuffer,38 lines,39 allMixed,40 stripFinalNewline,Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f
line 41why, one step back41 allFds,100% test coverage (#1018)ehmickybefore adoption9f65b86
lines 42–48why, one step back42 verboseInfo,43 streamInfo,44 }),45 onStreamEnd,46 ]);47 return output;48};