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

Function getRequestedDirection

lib/stdio/direction.js:29–36  ·  view source on GitHub ↗
({type, value, direction, optionName})

Source from the content-addressed store, hash-verified

27// The explicitly requested `direction` must not contradict a value that is intrinsically the other direction.
28// For example, `{value: writableStream, input: true}` is invalid since a writable value can only be an output.
29const getRequestedDirection = ({type, value, direction, optionName}) => {
30 const guessedDirection = guessStreamDirection[type](value);
31 if (direction === 'input' && guessedDirection === 'output') {
32 throw new TypeError(`The \`${optionName}\` option is invalid: \`input: true\` cannot be used with a writable value, which is always an output.`);
33 }
34
35 return direction ?? guessedDirection;
36};
37
38// `stdin`/`stdout`/`stderr` have a known direction
39const KNOWN_DIRECTIONS = ['input', 'output', 'output'];

Callers 1

getStdioItemDirectionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected