Skip to content
Myr

forward.js

This file

Path

lib/stdio/forward.js

18 lines · 1.1 KiB · JavaScript

Last changed by

Split files (#837)ehmickybefore adoption672c2d7

History of this file

Take it

Split files (#837)ehmickybefore adoption672c2d7

lines 1–18why, one step back
1// When the `std*: Iterable | WebStream | URL | filePath`, `input` or `inputFile` option is used, we pipe to `childProcess.std*`.
2// When the `std*: Array` option is used, we emulate some of the native values ('inherit', Node.js stream and file descriptor integer). To do so, we also need to pipe to `childProcess.std*`.3// Therefore the `std*` options must be either `pipe` or `overlapped`. Other values do not set `childProcess.std*`.4export const forwardStdio = stdioStreamsGroups => stdioStreamsGroups.map(stdioStreams => forwardStdioItem(stdioStreams));56// Whether `childProcess.std*` will be set7export const willPipeStreams = stdioStreams => PIPED_STDIO_VALUES.has(forwardStdioItem(stdioStreams));89const PIPED_STDIO_VALUES = new Set(['pipe', 'overlapped', undefined, null]);1011const forwardStdioItem = stdioStreams => {12 if (stdioStreams.length > 1) {13 return stdioStreams.some(({value}) => value === 'overlapped') ? 'overlapped' : 'pipe';14 }1516 const [stdioStream] = stdioStreams;17 return stdioStream.type !== 'native' && stdioStream.value !== 'overlapped' ? 'pipe' : stdioStream.value;18};