Skip to content
Myr

Improve syntax of `std*: filePath` option (#671)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by GitHub · parent 2ac81d4 · Browse files · 12 files+117 added−82 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

12 files+117 added−82 removed

  • tests:+58 added−45 removed
  • other:+59 added−37 removed

12 files+117 added−82 removed

modified:lib/stdio/async.js+4 added-2 removed
modified:lib/stdio/direction.js+1 added
modified:lib/stdio/handle.js+1 added-1 removed
69 unmodified lines
70For example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);71 }7273 if (isUnknownStdioString(type, value)) {74 throw new TypeError(`The \`${optionName}: filePath\` option must either be an absolute file path or start with \`.\`.`);74 throw new TypeError(`The \`${optionName}: { file: '...' }\` option must be used instead of \`${optionName}: '...'\`.`);75 }76};7778// Some `stdio` values require Execa to create streams.
20 unmodified lines
modified:lib/stdio/input.js+16 added-4 removed
modified:lib/stdio/sync.js+4 added-2 removed
23 unmodified lines
24};2526const addPropertiesSync = {27 input: {28 filePath: ({value}) => ({value: bufferToUint8Array(readFileSync(value)), type: 'uint8Array'}),28 fileUrl: ({value}) => ({value: bufferToUint8Array(readFileSync(value)), type: 'uint8Array'}),29 filePath: ({value}) => ({value: bufferToUint8Array(readFileSync(value.file)), type: 'uint8Array'}),30 webStream: forbiddenIfSync,31 nodeStream: forbiddenIfSync,32 iterable: forbiddenIfSync,33 native: forbiddenIfStreamSync,34 },35 output: {36 filePath: ({value}) => ({value: value.file}),37 webStream: forbiddenIfSync,38 nodeStream: forbiddenIfSync,39 iterable: forbiddenIfSync,40 uint8Array: forbiddenIfSync,
29 unmodified lines
70 if (result === null || direction === 'input') {71 return;72 }7372 if (type === 'filePath') {74 if (type === 'fileUrl' || type === 'filePath') {75 writeFileSync(value, result);76 }77};
modified:lib/stdio/type.js+14 added-9 removed
1import {isAbsolute} from 'node:path';1import {isStream as isNodeStream} from 'is-stream';2import {isUint8Array} from './utils.js';34// The `stdin`/`stdout`/`stderr` option can be of many types. This detects it.5export const getStdioOptionType = stdioOption => {7 if (isFileUrl(stdioOption) || isFilePath(stdioOption)) {6 if (isUrl(stdioOption)) {7 return 'fileUrl';8 }910 if (isFilePathObject(stdioOption)) {11 return 'filePath';12 }1314 if (isWebStream(stdioOption)) {
14 unmodified lines
2930 return 'native';31};3230const isUrlInstance = stdioOption => Object.prototype.toString.call(stdioOption) === '[object URL]';31const hasFileProtocol = url => url.protocol === 'file:';32const isFileUrl = stdioOption => isUrlInstance(stdioOption) && hasFileProtocol(stdioOption);33export const isRegularUrl = stdioOption => isUrlInstance(stdioOption) && !hasFileProtocol(stdioOption);33export const isUrl = stdioOption => Object.prototype.toString.call(stdioOption) === '[object URL]';34export const isRegularUrl = stdioOption => isUrl(stdioOption) && stdioOption.protocol !== 'file:';3535const stringIsFilePath = stdioOption => stdioOption.startsWith('.') || isAbsolute(stdioOption);36const isFilePath = stdioOption => typeof stdioOption === 'string' && stringIsFilePath(stdioOption);36const isFilePathObject = stdioOption => typeof stdioOption === 'object'37 && stdioOption !== null38 && Object.keys(stdioOption).length === 139 && isFilePathString(stdioOption.file);40export const isFilePathString = file => typeof file === 'string';4142export const isUnknownStdioString = (type, stdioOption) => type === 'native' && typeof stdioOption === 'string' && !KNOWN_STDIO_STRINGS.has(stdioOption);43const KNOWN_STDIO_STRINGS = new Set(['ipc', 'ignore', 'inherit', 'overlapped', 'pipe']);44
7 unmodified lines
52 && (typeof stdioOption[Symbol.asyncIterator] === 'function' || typeof stdioOption[Symbol.iterator] === 'function');5354// Convert types to human-friendly strings for error messages55export const TYPE_TO_MESSAGE = {52 filePath: 'a file path',56 fileUrl: 'a file URL',57 filePath: 'a file path string',58 webStream: 'a web stream',59 nodeStream: 'a Node.js stream',60 native: 'any value',61 iterable: 'an iterable',
3 unmodified lines
modified:lib/stream.js+3 added-3 removed
69 unmodified lines
70// Since we want to end those streams, they cannot be infinite, except for `process.stdout|stderr`.71// However, for the `stdin`/`input`/`inputFile` options, we only wait for errors, not completion.72// This is because source streams completion should end destination streams, but not the other way around.73// This allows for source streams to pipe to multiple destinations.74// We make an exception for `filePath`, since we create that source stream and we know it is piped to a single destination.74// We make an exception for `fileUrl` and `filePath`, since we create that source stream and we know it is piped to a single destination.75const waitForCustomStreamsEnd = customStreams => customStreams76 .filter(({value, type, direction}) => shouldWaitForCustomStream(value, type, direction))77 .map(({value}) => finished(value));7879const throwOnCustomStreamsError = customStreams => customStreams80 .filter(({value, type, direction}) => !shouldWaitForCustomStream(value, type, direction))81 .map(({value}) => throwOnStreamError(value));8283const shouldWaitForCustomStream = (value, type, direction) => (type === 'filePath' || direction === 'output')84 && !STANDARD_STREAMS.includes(value);83const shouldWaitForCustomStream = (value, type, direction) => (type === 'fileUrl' || type === 'filePath')84 || (direction === 'output' && !STANDARD_STREAMS.includes(value));8586const throwIfStreamError = stream => stream === null ? [] : [throwOnStreamError(stream)];8788const throwOnStreamError = async stream => {
59 unmodified lines
modified:test/stdio/array.js+2 added-2 removed
114 unmodified lines
115test('Cannot pass both readable and writable values to stdio[*] - process.stderr - sync', testInputOutput, process.stderr, execaSync);116117const testAmbiguousDirection = async (t, execaMethod) => {118 const [filePathOne, filePathTwo] = [tempfile(), tempfile()];119 await execaMethod('noop-fd3.js', ['foobar'], getStdioOption([filePathOne, filePathTwo]));119 await execaMethod('noop-fd3.js', ['foobar'], getStdioOption([{file: filePathOne}, {file: filePathTwo}]));120 t.deepEqual(await Promise.all([readFile(filePathOne, 'utf8'), readFile(filePathTwo, 'utf8')]), ['foobar\n', 'foobar\n']);121 await Promise.all([rm(filePathOne), rm(filePathTwo)]);122};123
2 unmodified lines
126127const testAmbiguousMultiple = async (t, fixtureName, getOptions) => {128 const filePath = tempfile();129 await writeFile(filePath, 'foobar');130 const {stdout} = await execa(fixtureName, getOptions([filePath, stringGenerator()]));130 const {stdout} = await execa(fixtureName, getOptions([{file: filePath}, stringGenerator()]));131 t.is(stdout, 'foobarfoobar');132 await rm(filePath);133};134
131 unmodified lines
modified:test/stdio/file-path.js+56 added-43 removed
12 unmodified lines
13const textEncoder = new TextEncoder();14const binaryFoobar = textEncoder.encode('foobar');15const nonFileUrl = new URL('https://example.com');1617const getRelativePath = filePath => relative('.', filePath);17const getAbsolutePath = file => ({file});18const getRelativePath = filePath => ({file: relative('.', filePath)});19const getStdinFilePath = file => ({stdin: {file}});2021const testStdinFile = async (t, mapFilePath, getOptions, execaMethod) => {22 const filePath = tempfile();23 await writeFile(filePath, 'foobar');
4 unmodified lines
2829test('inputFile can be a file URL', testStdinFile, pathToFileURL, getInputFileOption, execa);30test('stdin can be a file URL', testStdinFile, pathToFileURL, getStdinOption, execa);31test('inputFile can be an absolute file path', testStdinFile, identity, getInputFileOption, execa);30test('stdin can be an absolute file path', testStdinFile, identity, getStdinOption, execa);31test('inputFile can be a relative file path', testStdinFile, getRelativePath, getInputFileOption, execa);32test('stdin can be an absolute file path', testStdinFile, getAbsolutePath, getStdinOption, execa);33test('inputFile can be a relative file path', testStdinFile, identity, getInputFileOption, execa);34test('stdin can be a relative file path', testStdinFile, getRelativePath, getStdinOption, execa);35test('inputFile can be a file URL - sync', testStdinFile, pathToFileURL, getInputFileOption, execaSync);36test('stdin can be a file URL - sync', testStdinFile, pathToFileURL, getStdinOption, execaSync);37test('inputFile can be an absolute file path - sync', testStdinFile, identity, getInputFileOption, execaSync);36test('stdin can be an absolute file path - sync', testStdinFile, identity, getStdinOption, execaSync);37test('inputFile can be a relative file path - sync', testStdinFile, getRelativePath, getInputFileOption, execaSync);38test('stdin can be an absolute file path - sync', testStdinFile, getAbsolutePath, getStdinOption, execaSync);39test('inputFile can be a relative file path - sync', testStdinFile, identity, getInputFileOption, execaSync);40test('stdin can be a relative file path - sync', testStdinFile, getRelativePath, getStdinOption, execaSync);4142// eslint-disable-next-line max-params43const testOutputFile = async (t, mapFile, fixtureName, getOptions, execaMethod) => {
5 unmodified lines
4950test('stdout can be a file URL', testOutputFile, pathToFileURL, 'noop.js', getStdoutOption, execa);51test('stderr can be a file URL', testOutputFile, pathToFileURL, 'noop-err.js', getStderrOption, execa);52test('stdio[*] can be a file URL', testOutputFile, pathToFileURL, 'noop-fd3.js', getStdioOption, execa);51test('stdout can be an absolute file path', testOutputFile, identity, 'noop.js', getStdoutOption, execa);52test('stderr can be an absolute file path', testOutputFile, identity, 'noop-err.js', getStderrOption, execa);53test('stdio[*] can be an absolute file path', testOutputFile, identity, 'noop-fd3.js', getStdioOption, execa);53test('stdout can be an absolute file path', testOutputFile, getAbsolutePath, 'noop.js', getStdoutOption, execa);54test('stderr can be an absolute file path', testOutputFile, getAbsolutePath, 'noop-err.js', getStderrOption, execa);55test('stdio[*] can be an absolute file path', testOutputFile, getAbsolutePath, 'noop-fd3.js', getStdioOption, execa);56test('stdout can be a relative file path', testOutputFile, getRelativePath, 'noop.js', getStdoutOption, execa);57test('stderr can be a relative file path', testOutputFile, getRelativePath, 'noop-err.js', getStderrOption, execa);58test('stdio[*] can be a relative file path', testOutputFile, getRelativePath, 'noop-fd3.js', getStdioOption, execa);59test('stdout can be a file URL - sync', testOutputFile, pathToFileURL, 'noop.js', getStdoutOption, execaSync);60test('stderr can be a file URL - sync', testOutputFile, pathToFileURL, 'noop-err.js', getStderrOption, execaSync);61test('stdio[*] can be a file URL - sync', testOutputFile, pathToFileURL, 'noop-fd3.js', getStdioOption, execaSync);60test('stdout can be an absolute file path - sync', testOutputFile, identity, 'noop.js', getStdoutOption, execaSync);61test('stderr can be an absolute file path - sync', testOutputFile, identity, 'noop-err.js', getStderrOption, execaSync);62test('stdio[*] can be an absolute file path - sync', testOutputFile, identity, 'noop-fd3.js', getStdioOption, execaSync);62test('stdout can be an absolute file path - sync', testOutputFile, getAbsolutePath, 'noop.js', getStdoutOption, execaSync);63test('stderr can be an absolute file path - sync', testOutputFile, getAbsolutePath, 'noop-err.js', getStderrOption, execaSync);64test('stdio[*] can be an absolute file path - sync', testOutputFile, getAbsolutePath, 'noop-fd3.js', getStdioOption, execaSync);65test('stdout can be a relative file path - sync', testOutputFile, getRelativePath, 'noop.js', getStdoutOption, execaSync);66test('stderr can be a relative file path - sync', testOutputFile, getRelativePath, 'noop-err.js', getStderrOption, execaSync);67test('stdio[*] can be a relative file path - sync', testOutputFile, getRelativePath, 'noop-fd3.js', getStdioOption, execaSync);68
13 unmodified lines
82test('stdout cannot be a non-file URL - sync', testStdioNonFileUrl, getStdoutOption, execaSync);83test('stderr cannot be a non-file URL - sync', testStdioNonFileUrl, getStderrOption, execaSync);84test('stdio[*] cannot be a non-file URL - sync', testStdioNonFileUrl, getStdioOption, execaSync);8584const testInputFileValidUrl = async (t, execaMethod) => {86const testInvalidInputFile = (t, execaMethod) => {87 t.throws(() => {88 execaMethod('noop.js', getInputFileOption(false));89 }, {message: /a file path string or a file URL/});90};9192test('inputFile must be a file URL or string', testInvalidInputFile, execa);93test('inputFile must be a file URL or string - sync', testInvalidInputFile, execaSync);9495const testInputFileValidUrl = async (t, getOptions, execaMethod) => {96 const filePath = tempfile();97 await writeFile(filePath, 'foobar');98 const currentCwd = process.cwd();99 process.chdir(dirname(filePath));100101 try {91 const {stdout} = await execaMethod('stdin.js', {inputFile: basename(filePath)});102 const {stdout} = await execaMethod('stdin.js', getOptions(basename(filePath)));103 t.is(stdout, 'foobar');104 } finally {105 process.chdir(currentCwd);106 await rm(filePath);107 }108};10999test.serial('inputFile does not need to start with . when being a relative file path', testInputFileValidUrl, execa);100test.serial('inputFile does not need to start with . when being a relative file path - sync', testInputFileValidUrl, execaSync);110test.serial('inputFile does not need to start with . when being a relative file path', testInputFileValidUrl, getInputFileOption, execa);111test.serial('stdin does not need to start with . when being a relative file path', testInputFileValidUrl, getStdinFilePath, execa);112test.serial('inputFile does not need to start with . when being a relative file path - sync', testInputFileValidUrl, getInputFileOption, execaSync);113test.serial('stdin does not need to start with . when being a relative file path - sync', testInputFileValidUrl, getStdinFilePath, execaSync);114102const testStdioValidUrl = (t, getOptions, execaMethod) => {115const testFilePathObject = (t, getOptions, execaMethod) => {116 t.throws(() => {117 execaMethod('noop.js', getOptions('foobar'));105 }, {message: /absolute file path/});118 }, {message: /must be used/});119};120108test('stdin must start with . when being a relative file path', testStdioValidUrl, getStdinOption, execa);109test('stdout must start with . when being a relative file path', testStdioValidUrl, getStdoutOption, execa);110test('stderr must start with . when being a relative file path', testStdioValidUrl, getStderrOption, execa);111test('stdio[*] must start with . when being a relative file path', testStdioValidUrl, getStdioOption, execa);112test('stdin must start with . when being a relative file path - sync', testStdioValidUrl, getStdinOption, execaSync);113test('stdout must start with . when being a relative file path - sync', testStdioValidUrl, getStdoutOption, execaSync);114test('stderr must start with . when being a relative file path - sync', testStdioValidUrl, getStderrOption, execaSync);115test('stdio[*] must start with . when being a relative file path - sync', testStdioValidUrl, getStdioOption, execaSync);121test('stdin must be an object when it is a file path string', testFilePathObject, getStdinOption, execa);122test('stdout must be an object when it is a file path string', testFilePathObject, getStdoutOption, execa);123test('stderr must be an object when it is a file path string', testFilePathObject, getStderrOption, execa);124test('stdio[*] must be an object when it is a file path string', testFilePathObject, getStdioOption, execa);125test('stdin be an object when it is a file path string - sync', testFilePathObject, getStdinOption, execaSync);126test('stdout be an object when it is a file path string - sync', testFilePathObject, getStdoutOption, execaSync);127test('stderr be an object when it is a file path string - sync', testFilePathObject, getStderrOption, execaSync);128test('stdio[*] must be an object when it is a file path string - sync', testFilePathObject, getStdioOption, execaSync);129130const testFileError = async (t, mapFile, getOptions) => {131 await t.throwsAsync(132 execa('noop.js', getOptions(mapFile('./unknown/file'))),
6 unmodified lines
139test('stdout file URL errors should be handled', testFileError, pathToFileURL, getStdoutOption);140test('stderr file URL errors should be handled', testFileError, pathToFileURL, getStderrOption);141test('stdio[*] file URL errors should be handled', testFileError, pathToFileURL, getStdioOption);142test('inputFile file path errors should be handled', testFileError, identity, getInputFileOption);130test('stdin file path errors should be handled', testFileError, identity, getStdinOption);131test('stdout file path errors should be handled', testFileError, identity, getStdoutOption);132test('stderr file path errors should be handled', testFileError, identity, getStderrOption);133test('stdio[*] file path errors should be handled', testFileError, identity, getStdioOption);143test('stdin file path errors should be handled', testFileError, getAbsolutePath, getStdinOption);144test('stdout file path errors should be handled', testFileError, getAbsolutePath, getStdoutOption);145test('stderr file path errors should be handled', testFileError, getAbsolutePath, getStderrOption);146test('stdio[*] file path errors should be handled', testFileError, getAbsolutePath, getStdioOption);147148const testFileErrorSync = (t, mapFile, getOptions) => {149 t.throws(() => {150 execaSync('noop.js', getOptions(mapFile('./unknown/file')));
5 unmodified lines
156test('stdout file URL errors should be handled - sync', testFileErrorSync, pathToFileURL, getStdoutOption);157test('stderr file URL errors should be handled - sync', testFileErrorSync, pathToFileURL, getStderrOption);158test('stdio[*] file URL errors should be handled - sync', testFileErrorSync, pathToFileURL, getStdioOption);159test('inputFile file path errors should be handled - sync', testFileErrorSync, identity, getInputFileOption);147test('stdin file path errors should be handled - sync', testFileErrorSync, identity, getStdinOption);148test('stdout file path errors should be handled - sync', testFileErrorSync, identity, getStdoutOption);149test('stderr file path errors should be handled - sync', testFileErrorSync, identity, getStderrOption);150test('stdio[*] file path errors should be handled - sync', testFileErrorSync, identity, getStdioOption);160test('stdin file path errors should be handled - sync', testFileErrorSync, getAbsolutePath, getStdinOption);161test('stdout file path errors should be handled - sync', testFileErrorSync, getAbsolutePath, getStdoutOption);162test('stderr file path errors should be handled - sync', testFileErrorSync, getAbsolutePath, getStderrOption);163test('stdio[*] file path errors should be handled - sync', testFileErrorSync, getAbsolutePath, getStdioOption);164165const testInputFile = async (t, execaMethod) => {166 const inputFile = tempfile();167 await writeFile(inputFile, 'foobar');
28 unmodified lines
196const getStringInput = () => ({input: 'foobar'});197const getBinaryInput = () => ({input: binaryFoobar});198199test('input String and inputFile can be both set', testMultipleInputs, [getInputFileOption, getStringInput], execa);187test('input String and stdin can be both set', testMultipleInputs, [getStdinOption, getStringInput], execa);200test('input String and stdin can be both set', testMultipleInputs, [getStdinFilePath, getStringInput], execa);201test('input Uint8Array and inputFile can be both set', testMultipleInputs, [getInputFileOption, getBinaryInput], execa);189test('input Uint8Array and stdin can be both set', testMultipleInputs, [getStdinOption, getBinaryInput], execa);190test('stdin and inputFile can be both set', testMultipleInputs, [getStdinOption, getInputFileOption], execa);191test('input String, stdin and inputFile can be all set', testMultipleInputs, [getInputFileOption, getStdinOption, getStringInput], execa);192test('input Uint8Array, stdin and inputFile can be all set', testMultipleInputs, [getInputFileOption, getStdinOption, getBinaryInput], execa);202test('input Uint8Array and stdin can be both set', testMultipleInputs, [getStdinFilePath, getBinaryInput], execa);203test('stdin and inputFile can be both set', testMultipleInputs, [getStdinFilePath, getInputFileOption], execa);204test('input String, stdin and inputFile can be all set', testMultipleInputs, [getInputFileOption, getStdinFilePath, getStringInput], execa);205test('input Uint8Array, stdin and inputFile can be all set', testMultipleInputs, [getInputFileOption, getStdinFilePath, getBinaryInput], execa);206test('input String and inputFile can be both set - sync', testMultipleInputs, [getInputFileOption, getStringInput], execaSync);194test('input String and stdin can be both set - sync', testMultipleInputs, [getStdinOption, getStringInput], execaSync);207test('input String and stdin can be both set - sync', testMultipleInputs, [getStdinFilePath, getStringInput], execaSync);208test('input Uint8Array and inputFile can be both set - sync', testMultipleInputs, [getInputFileOption, getBinaryInput], execaSync);196test('input Uint8Array and stdin can be both set - sync', testMultipleInputs, [getStdinOption, getBinaryInput], execaSync);197test('stdin and inputFile can be both set - sync', testMultipleInputs, [getStdinOption, getInputFileOption], execaSync);198test('input String, stdin and inputFile can be all set - sync', testMultipleInputs, [getInputFileOption, getStdinOption, getStringInput], execaSync);199test('input Uint8Array, stdin and inputFile can be all set - sync', testMultipleInputs, [getInputFileOption, getStdinOption, getBinaryInput], execaSync);209test('input Uint8Array and stdin can be both set - sync', testMultipleInputs, [getStdinFilePath, getBinaryInput], execaSync);210test('stdin and inputFile can be both set - sync', testMultipleInputs, [getStdinFilePath, getInputFileOption], execaSync);211test('input String, stdin and inputFile can be all set - sync', testMultipleInputs, [getInputFileOption, getStdinFilePath, getStringInput], execaSync);212test('input Uint8Array, stdin and inputFile can be all set - sync', testMultipleInputs, [getInputFileOption, getStdinFilePath, getBinaryInput], execaSync);
modified:index.d.ts+4 added-4 removed
11 unmodified lines
12 | 'ipc'13 | number14 | undefined15 | URL16 | string;16 | {file: string};1718type InputStdioOption =19 | Iterable<string | Uint8Array>20 | AsyncIterable<string | Uint8Array>
97 unmodified lines
118 - `'ipc'`: Sets an [IPC channel](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback). You can also use `execaNode()` instead.119 - `'inherit'`: Re-use the current process' `stdin`.120 - an integer: Re-use a specific file descriptor from the current process.121 - a Node.js `Readable` stream.122 - a file path. If relative, it must start with `.`.122 - `{ file: 'path' }` object.123 - a file URL.124 - a web [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream).125 - an [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol) or an [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)126 - an `Uint8Array`.
12 unmodified lines
139 - `'ipc'`: Sets an [IPC channel](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback). You can also use `execaNode()` instead.140 - `'inherit'`: Re-use the current process' `stdout`.141 - an integer: Re-use a specific file descriptor from the current process.142 - a Node.js `Writable` stream.143 - a file path. If relative, it must start with `.`.143 - `{ file: 'path' }` object.144 - a file URL.145 - a web [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream).146147 This can be an [array of values](https://github.com/sindresorhus/execa#redirect-stdinstdoutstderr-to-multiple-destinations) such as `['inherit', 'pipe']` or `[filePath, 'pipe']`.
10 unmodified lines
158 - `'ipc'`: Sets an [IPC channel](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback). You can also use `execaNode()` instead.159 - `'inherit'`: Re-use the current process' `stderr`.160 - an integer: Re-use a specific file descriptor from the current process.161 - a Node.js `Writable` stream.162 - a file path. If relative, it must start with `.`.162 - `{ file: 'path' }` object.163 - a file URL.164 - a web [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream).165166 This can be an [array of values](https://github.com/sindresorhus/execa#redirect-stdinstdoutstderr-to-multiple-destinations) such as `['inherit', 'pipe']` or `[filePath, 'pipe']`.
917 unmodified lines
modified:index.test-d.ts+9 added-9 removed
188 unmodified lines
189expectError(execa('unicorns', {stdin: numberGenerator()}));190expectError(execa('unicorns', {stdin: [numberGenerator()]}));191execa('unicorns', {stdin: fileUrl});192execa('unicorns', {stdin: [fileUrl]});193execa('unicorns', {stdin: './test'});194execa('unicorns', {stdin: ['./test']});193execa('unicorns', {stdin: {file: './test'}});194execa('unicorns', {stdin: [{file: './test'}]});195execa('unicorns', {stdin: 1});196execa('unicorns', {stdin: [1]});197execa('unicorns', {stdin: undefined});198execa('unicorns', {stdin: [undefined]});
19 unmodified lines
218expectError(execa('unicorns', {stdout: new ReadableStream()}));219expectError(execa('unicorn', {stdout: [new ReadableStream()]}));220execa('unicorns', {stdout: fileUrl});221execa('unicorns', {stdout: [fileUrl]});222execa('unicorns', {stdout: './test'});223execa('unicorns', {stdout: ['./test']});222execa('unicorns', {stdout: {file: './test'}});223execa('unicorns', {stdout: [{file: './test'}]});224execa('unicorns', {stdout: 1});225execa('unicorns', {stdout: [1]});226execa('unicorns', {stdout: undefined});227execa('unicorns', {stdout: [undefined]});
19 unmodified lines
247expectError(execa('unicorns', {stderr: new ReadableStream()}));248expectError(execa('unicorns', {stderr: [new ReadableStream()]}));249execa('unicorns', {stderr: fileUrl});250execa('unicorns', {stderr: [fileUrl]});251execa('unicorns', {stderr: './test'});252execa('unicorns', {stderr: ['./test']});251execa('unicorns', {stderr: {file: './test'}});252execa('unicorns', {stderr: [{file: './test'}]});253execa('unicorns', {stderr: 1});254execa('unicorns', {stderr: [1]});255execa('unicorns', {stderr: undefined});256execa('unicorns', {stderr: [undefined]});
13 unmodified lines
270execa('unicorns', {stdio: 'inherit'});271expectError(execa('unicorns', {stdio: 'ipc'}));272expectError(execa('unicorns', {stdio: 1}));273expectError(execa('unicorns', {stdio: fileUrl}));274expectError(execa('unicorns', {stdio: './test'}));274expectError(execa('unicorns', {stdio: {file: './test'}}));275expectError(execa('unicorns', {stdio: new Writable()}));276expectError(execa('unicorns', {stdio: new Readable()}));277expectError(execa('unicorns', {stdio: new WritableStream()}));278expectError(execa('unicorns', {stdio: new ReadableStream()}));
22 unmodified lines
301 process.stdin,302 1,303 undefined,304 fileUrl,305 './test',305 {file: './test'},306 new Writable(),307 new Readable(),308 new WritableStream(),309 new ReadableStream(),
13 unmodified lines
323 [process.stdin],324 [1],325 [undefined],326 [fileUrl],327 ['./test'],327 [{file: './test'}],328 [new Writable()],329 [new Readable()],330 [new WritableStream()],331 [new ReadableStream()],
154 unmodified lines
modified:readme.md+3 added-3 removed
581 unmodified lines
582- `'ipc'`: Sets an [IPC channel](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback). You can also use [`execaNode()`](#execanodescriptpath-arguments-options) instead.583- `'inherit'`: Re-use the current process' `stdin`.584- an integer: Re-use a specific file descriptor from the current process.585- a [Node.js `Readable` stream](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr).586- a file path. If relative, it must start with `.`.586- `{ file: 'path' }` object.587- a file URL.588- a web [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream).589- an [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol) or an [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)590- an `Uint8Array`.
12 unmodified lines
603- `'ipc'`: Sets an [IPC channel](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback). You can also use [`execaNode()`](#execanodescriptpath-arguments-options) instead.604- `'inherit'`: Re-use the current process' `stdout`.605- an integer: Re-use a specific file descriptor from the current process.606- a [Node.js `Writable` stream](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr).607- a file path. If relative, it must start with `.`.607- `{ file: 'path' }` object.608- a file URL.609- a web [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream).610611This can be an [array of values](#redirect-stdinstdoutstderr-to-multiple-destinations) such as `['inherit', 'pipe']` or `[filePath, 'pipe']`.
10 unmodified lines
622- `'ipc'`: Sets an [IPC channel](https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback). You can also use [`execaNode()`](#execanodescriptpath-arguments-options) instead.623- `'inherit'`: Re-use the current process' `stderr`.624- an integer: Re-use a specific file descriptor from the current process.625- a [Node.js `Writable` stream](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr).626- a file path. If relative, it must start with `.`.626- `{ file: 'path' }` object.627- a file URL.628- a web [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream).629630This can be an [array of values](#redirect-stdinstdoutstderr-to-multiple-destinations) such as `['inherit', 'pipe']` or `[filePath, 'pipe']`.
297 unmodified lines