MCPcopy Create free account
hub / github.com/sindresorhus/execa / getFileDescriptor

Function getFileDescriptor

lib/stdio/handle.js:39–59  ·  view source on GitHub ↗
({stdioOption, fdNumber, options, isSync})

Source from the content-addressed store, hash-verified

37};
38
39const getFileDescriptor = ({stdioOption, fdNumber, options, isSync}) => {
40 const optionName = getStreamName(fdNumber);
41 const {stdioItems: initialStdioItems, isStdioArray} = initializeStdioItems({
42 stdioOption,
43 fdNumber,
44 options,
45 optionName,
46 });
47 const direction = getStreamDirection(initialStdioItems, fdNumber, optionName);
48 const stdioItems = initialStdioItems.map(stdioItem => handleNativeStream({
49 stdioItem,
50 isStdioArray,
51 fdNumber,
52 direction,
53 isSync,
54 }));
55 const normalizedStdioItems = normalizeTransforms(stdioItems, optionName, direction, options);
56 const objectMode = getFdObjectMode(normalizedStdioItems, direction);
57 validateFileObjectMode(normalizedStdioItems, objectMode);
58 return {direction, objectMode, stdioItems: normalizedStdioItems};
59};
60
61// We make sure passing an array with a single item behaves the same as passing that item without an array.
62// This is what users would expect.

Callers 1

handleStdioFunction · 0.85

Calls 7

getStreamNameFunction · 0.90
getStreamDirectionFunction · 0.90
handleNativeStreamFunction · 0.90
normalizeTransformsFunction · 0.90
getFdObjectModeFunction · 0.90
initializeStdioItemsFunction · 0.85
validateFileObjectModeFunction · 0.85

Tested by

no test coverage detected