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
Provenance
- Commit
90e0e13- Tree
a0dbcc8- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
2ac81d4
12 files changed+117 added−82 removed
modified:lib/stdio/async.js+4 added-2 removed
12 unmodified lines131415161717181920212223242425262728293028 unmodified lines12 unmodified lines};
const addPropertiesAsync = { input: { filePath: ({value}) => ({value: createReadStream(value)}), fileUrl: ({value}) => ({value: createReadStream(value)}), filePath: ({value}) => ({value: createReadStream(value.file)}), webStream: ({value}) => ({value: Readable.fromWeb(value)}), iterable: ({value}) => ({value: Readable.from(value)}), string: ({value}) => ({value: Readable.from(value)}), uint8Array: ({value}) => ({value: Readable.from(Buffer.from(value))}), }, output: { filePath: ({value}) => ({value: createWriteStream(value)}), fileUrl: ({value}) => ({value: createWriteStream(value)}), filePath: ({value}) => ({value: createWriteStream(value.file)}), webStream: ({value}) => ({value: Writable.fromWeb(value)}), iterable: forbiddenIfAsync, uint8Array: forbiddenIfAsync, },28 unmodified linesmodified:lib/stdio/direction.js+1 added
26 unmodified lines27282930313233343529 unmodified lines26 unmodified linesconst KNOWN_DIRECTIONS = ['input', 'output', 'output'];
// `string` can only be added through the `input` option, i.e. does not need to be handled hereconst guessStreamDirection = { fileUrl: () => undefined, filePath: () => undefined, iterable: () => 'input', uint8Array: () => 'input', webStream: stdioOption => isWritableStream(stdioOption) ? 'output' : 'input',29 unmodified linesmodified:lib/stdio/handle.js+1 added-1 removed
69 unmodified lines70 For example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);71 }72 73 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 };77 78 // Some `stdio` values require Execa to create streams.20 unmodified linesmodified:lib/stdio/input.js+16 added-4 removed
1234567891011111213141516171718192021228 unmodified lines31323334343535363738394041424344454647484950import {isReadableStream} from 'is-stream';import {isUrl, isFilePathString} from './type.js';import {isUint8Array} from './utils.js';
// Append the `stdin` option with the `input` and `inputFile` optionsexport const handleInputOptions = ({input, inputFile}) => [ handleInputOption(input), handleInputFileOption(inputFile),].filter(Boolean);
const handleInputOption = input => input === undefined ? undefined : { type: getType(input), type: getInputType(input), value: input, optionName: 'input', index: 0,};
const getType = input => {const getInputType = input => { if (isReadableStream(input)) { return 'nodeStream'; }
8 unmodified lines throw new Error('The `input` option must be a string, a Uint8Array or a Node.js Readable stream.');};
const handleInputFileOption = inputFile => inputFile === undefined ? undefined : { type: 'filePath', value: inputFile, ...getInputFileType(inputFile), optionName: 'inputFile', index: 0,};
const getInputFileType = inputFile => { if (isUrl(inputFile)) { return {type: 'fileUrl', value: inputFile}; }
if (isFilePathString(inputFile)) { return {type: 'filePath', value: {file: inputFile}}; }
throw new Error('The `inputFile` option must be a file path string or a file URL.');};modified:lib/stdio/sync.js+4 added-2 removed
23 unmodified lines24 };25 26 const 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 lines70 if (result === null || direction === 'input') {71 return;72 }73 72- if (type === 'filePath') {74+ if (type === 'fileUrl' || type === 'filePath') {75 writeFileSync(value, result);76 }77 };modified:lib/stdio/type.js+14 added-9 removed
1-import {isAbsolute} from 'node:path';1 import {isStream as isNodeStream} from 'is-stream';2 import {isUint8Array} from './utils.js';3 4 // The `stdin`/`stdout`/`stderr` option can be of many types. This detects it.5 export const getStdioOptionType = stdioOption => {7- if (isFileUrl(stdioOption) || isFilePath(stdioOption)) {6+ if (isUrl(stdioOption)) {7+ return 'fileUrl';8+ }9+10+ if (isFilePathObject(stdioOption)) {11 return 'filePath';12 }13 14 if (isWebStream(stdioOption)) {14 unmodified lines29 30 return 'native';31 };32 30-const isUrlInstance = stdioOption => Object.prototype.toString.call(stdioOption) === '[object URL]';31-const hasFileProtocol = url => url.protocol === 'file:';32-const isFileUrl = stdioOption => isUrlInstance(stdioOption) && hasFileProtocol(stdioOption);33-export const isRegularUrl = stdioOption => isUrlInstance(stdioOption) && !hasFileProtocol(stdioOption);33+export const isUrl = stdioOption => Object.prototype.toString.call(stdioOption) === '[object URL]';34+export const isRegularUrl = stdioOption => isUrl(stdioOption) && stdioOption.protocol !== 'file:';35 35-const stringIsFilePath = stdioOption => stdioOption.startsWith('.') || isAbsolute(stdioOption);36-const isFilePath = stdioOption => typeof stdioOption === 'string' && stringIsFilePath(stdioOption);36+const isFilePathObject = stdioOption => typeof stdioOption === 'object'37+ && stdioOption !== null38+ && Object.keys(stdioOption).length === 139+ && isFilePathString(stdioOption.file);40+export const isFilePathString = file => typeof file === 'string';41 42 export const isUnknownStdioString = (type, stdioOption) => type === 'native' && typeof stdioOption === 'string' && !KNOWN_STDIO_STRINGS.has(stdioOption);43 const KNOWN_STDIO_STRINGS = new Set(['ipc', 'ignore', 'inherit', 'overlapped', 'pipe']);44 7 unmodified lines52 && (typeof stdioOption[Symbol.asyncIterator] === 'function' || typeof stdioOption[Symbol.iterator] === 'function');53 54 // Convert types to human-friendly strings for error messages55 export 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 linesmodified:lib/stream.js+3 added-3 removed
69 unmodified lines70 // 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.75 const waitForCustomStreamsEnd = customStreams => customStreams76 .filter(({value, type, direction}) => shouldWaitForCustomStream(value, type, direction))77 .map(({value}) => finished(value));78 79 const throwOnCustomStreamsError = customStreams => customStreams80 .filter(({value, type, direction}) => !shouldWaitForCustomStream(value, type, direction))81 .map(({value}) => throwOnStreamError(value));82 83-const shouldWaitForCustomStream = (value, type, direction) => (type === 'filePath' || direction === 'output')84- && !STANDARD_STREAMS.includes(value);83+const shouldWaitForCustomStream = (value, type, direction) => (type === 'fileUrl' || type === 'filePath')84+ || (direction === 'output' && !STANDARD_STREAMS.includes(value));85 86 const throwIfStreamError = stream => stream === null ? [] : [throwOnStreamError(stream)];87 88 const throwOnStreamError = async stream => {59 unmodified linesmodified:test/stdio/array.js+2 added-2 removed
114 unmodified lines115 test('Cannot pass both readable and writable values to stdio[*] - process.stderr - sync', testInputOutput, process.stderr, execaSync);116 117 const 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 lines126 127 const 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 linesmodified:test/stdio/file-path.js+56 added-43 removed
12 unmodified lines13 const textEncoder = new TextEncoder();14 const binaryFoobar = textEncoder.encode('foobar');15 const nonFileUrl = new URL('https://example.com');16 17-const getRelativePath = filePath => relative('.', filePath);17+const getAbsolutePath = file => ({file});18+const getRelativePath = filePath => ({file: relative('.', filePath)});19+const getStdinFilePath = file => ({stdin: {file}});20 21 const testStdinFile = async (t, mapFilePath, getOptions, execaMethod) => {22 const filePath = tempfile();23 await writeFile(filePath, 'foobar');4 unmodified lines28 29 test('inputFile can be a file URL', testStdinFile, pathToFileURL, getInputFileOption, execa);30 test('stdin can be a file URL', testStdinFile, pathToFileURL, getStdinOption, execa);31 test('inputFile can be an absolute file path', testStdinFile, identity, getInputFileOption, execa);30-test('stdin can be an absolute file path', testStdinFile, identity, getStdinOption, execa);31-test('inputFile can be a relative file path', testStdinFile, getRelativePath, getInputFileOption, execa);32+test('stdin can be an absolute file path', testStdinFile, getAbsolutePath, getStdinOption, execa);33+test('inputFile can be a relative file path', testStdinFile, identity, getInputFileOption, execa);34 test('stdin can be a relative file path', testStdinFile, getRelativePath, getStdinOption, execa);35 test('inputFile can be a file URL - sync', testStdinFile, pathToFileURL, getInputFileOption, execaSync);36 test('stdin can be a file URL - sync', testStdinFile, pathToFileURL, getStdinOption, execaSync);37 test('inputFile can be an absolute file path - sync', testStdinFile, identity, getInputFileOption, execaSync);36-test('stdin can be an absolute file path - sync', testStdinFile, identity, getStdinOption, execaSync);37-test('inputFile can be a relative file path - sync', testStdinFile, getRelativePath, getInputFileOption, execaSync);38+test('stdin can be an absolute file path - sync', testStdinFile, getAbsolutePath, getStdinOption, execaSync);39+test('inputFile can be a relative file path - sync', testStdinFile, identity, getInputFileOption, execaSync);40 test('stdin can be a relative file path - sync', testStdinFile, getRelativePath, getStdinOption, execaSync);41 42 // eslint-disable-next-line max-params43 const testOutputFile = async (t, mapFile, fixtureName, getOptions, execaMethod) => {5 unmodified lines49 50 test('stdout can be a file URL', testOutputFile, pathToFileURL, 'noop.js', getStdoutOption, execa);51 test('stderr can be a file URL', testOutputFile, pathToFileURL, 'noop-err.js', getStderrOption, execa);52 test('stdio[*] can be a file URL', testOutputFile, pathToFileURL, 'noop-fd3.js', getStdioOption, execa);51-test('stdout can be an absolute file path', testOutputFile, identity, 'noop.js', getStdoutOption, execa);52-test('stderr can be an absolute file path', testOutputFile, identity, 'noop-err.js', getStderrOption, execa);53-test('stdio[*] can be an absolute file path', testOutputFile, identity, 'noop-fd3.js', getStdioOption, execa);53+test('stdout can be an absolute file path', testOutputFile, getAbsolutePath, 'noop.js', getStdoutOption, execa);54+test('stderr can be an absolute file path', testOutputFile, getAbsolutePath, 'noop-err.js', getStderrOption, execa);55+test('stdio[*] can be an absolute file path', testOutputFile, getAbsolutePath, 'noop-fd3.js', getStdioOption, execa);56 test('stdout can be a relative file path', testOutputFile, getRelativePath, 'noop.js', getStdoutOption, execa);57 test('stderr can be a relative file path', testOutputFile, getRelativePath, 'noop-err.js', getStderrOption, execa);58 test('stdio[*] can be a relative file path', testOutputFile, getRelativePath, 'noop-fd3.js', getStdioOption, execa);59 test('stdout can be a file URL - sync', testOutputFile, pathToFileURL, 'noop.js', getStdoutOption, execaSync);60 test('stderr can be a file URL - sync', testOutputFile, pathToFileURL, 'noop-err.js', getStderrOption, execaSync);61 test('stdio[*] can be a file URL - sync', testOutputFile, pathToFileURL, 'noop-fd3.js', getStdioOption, execaSync);60-test('stdout can be an absolute file path - sync', testOutputFile, identity, 'noop.js', getStdoutOption, execaSync);61-test('stderr can be an absolute file path - sync', testOutputFile, identity, 'noop-err.js', getStderrOption, execaSync);62-test('stdio[*] can be an absolute file path - sync', testOutputFile, identity, 'noop-fd3.js', getStdioOption, execaSync);62+test('stdout can be an absolute file path - sync', testOutputFile, getAbsolutePath, 'noop.js', getStdoutOption, execaSync);63+test('stderr can be an absolute file path - sync', testOutputFile, getAbsolutePath, 'noop-err.js', getStderrOption, execaSync);64+test('stdio[*] can be an absolute file path - sync', testOutputFile, getAbsolutePath, 'noop-fd3.js', getStdioOption, execaSync);65 test('stdout can be a relative file path - sync', testOutputFile, getRelativePath, 'noop.js', getStdoutOption, execaSync);66 test('stderr can be a relative file path - sync', testOutputFile, getRelativePath, 'noop-err.js', getStderrOption, execaSync);67 test('stdio[*] can be a relative file path - sync', testOutputFile, getRelativePath, 'noop-fd3.js', getStdioOption, execaSync);68 13 unmodified lines82 test('stdout cannot be a non-file URL - sync', testStdioNonFileUrl, getStdoutOption, execaSync);83 test('stderr cannot be a non-file URL - sync', testStdioNonFileUrl, getStderrOption, execaSync);84 test('stdio[*] cannot be a non-file URL - sync', testStdioNonFileUrl, getStdioOption, execaSync);85 84-const testInputFileValidUrl = async (t, execaMethod) => {86+const testInvalidInputFile = (t, execaMethod) => {87+ t.throws(() => {88+ execaMethod('noop.js', getInputFileOption(false));89+ }, {message: /a file path string or a file URL/});90+};91+92+test('inputFile must be a file URL or string', testInvalidInputFile, execa);93+test('inputFile must be a file URL or string - sync', testInvalidInputFile, execaSync);94+95+const testInputFileValidUrl = async (t, getOptions, execaMethod) => {96 const filePath = tempfile();97 await writeFile(filePath, 'foobar');98 const currentCwd = process.cwd();99 process.chdir(dirname(filePath));100 101 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 };109 99-test.serial('inputFile does not need to start with . when being a relative file path', testInputFileValidUrl, execa);100-test.serial('inputFile does not need to start with . when being a relative file path - sync', testInputFileValidUrl, execaSync);110+test.serial('inputFile does not need to start with . when being a relative file path', testInputFileValidUrl, getInputFileOption, execa);111+test.serial('stdin does not need to start with . when being a relative file path', testInputFileValidUrl, getStdinFilePath, execa);112+test.serial('inputFile does not need to start with . when being a relative file path - sync', testInputFileValidUrl, getInputFileOption, execaSync);113+test.serial('stdin does not need to start with . when being a relative file path - sync', testInputFileValidUrl, getStdinFilePath, execaSync);114 102-const testStdioValidUrl = (t, getOptions, execaMethod) => {115+const testFilePathObject = (t, getOptions, execaMethod) => {116 t.throws(() => {117 execaMethod('noop.js', getOptions('foobar'));105- }, {message: /absolute file path/});118+ }, {message: /must be used/});119 };120 108-test('stdin must start with . when being a relative file path', testStdioValidUrl, getStdinOption, execa);109-test('stdout must start with . when being a relative file path', testStdioValidUrl, getStdoutOption, execa);110-test('stderr must start with . when being a relative file path', testStdioValidUrl, getStderrOption, execa);111-test('stdio[*] must start with . when being a relative file path', testStdioValidUrl, getStdioOption, execa);112-test('stdin must start with . when being a relative file path - sync', testStdioValidUrl, getStdinOption, execaSync);113-test('stdout must start with . when being a relative file path - sync', testStdioValidUrl, getStdoutOption, execaSync);114-test('stderr must start with . when being a relative file path - sync', testStdioValidUrl, getStderrOption, execaSync);115-test('stdio[*] must start with . when being a relative file path - sync', testStdioValidUrl, getStdioOption, execaSync);121+test('stdin must be an object when it is a file path string', testFilePathObject, getStdinOption, execa);122+test('stdout must be an object when it is a file path string', testFilePathObject, getStdoutOption, execa);123+test('stderr must be an object when it is a file path string', testFilePathObject, getStderrOption, execa);124+test('stdio[*] must be an object when it is a file path string', testFilePathObject, getStdioOption, execa);125+test('stdin be an object when it is a file path string - sync', testFilePathObject, getStdinOption, execaSync);126+test('stdout be an object when it is a file path string - sync', testFilePathObject, getStdoutOption, execaSync);127+test('stderr be an object when it is a file path string - sync', testFilePathObject, getStderrOption, execaSync);128+test('stdio[*] must be an object when it is a file path string - sync', testFilePathObject, getStdioOption, execaSync);129 130 const testFileError = async (t, mapFile, getOptions) => {131 await t.throwsAsync(132 execa('noop.js', getOptions(mapFile('./unknown/file'))),6 unmodified lines139 test('stdout file URL errors should be handled', testFileError, pathToFileURL, getStdoutOption);140 test('stderr file URL errors should be handled', testFileError, pathToFileURL, getStderrOption);141 test('stdio[*] file URL errors should be handled', testFileError, pathToFileURL, getStdioOption);142 test('inputFile file path errors should be handled', testFileError, identity, getInputFileOption);130-test('stdin file path errors should be handled', testFileError, identity, getStdinOption);131-test('stdout file path errors should be handled', testFileError, identity, getStdoutOption);132-test('stderr file path errors should be handled', testFileError, identity, getStderrOption);133-test('stdio[*] file path errors should be handled', testFileError, identity, getStdioOption);143+test('stdin file path errors should be handled', testFileError, getAbsolutePath, getStdinOption);144+test('stdout file path errors should be handled', testFileError, getAbsolutePath, getStdoutOption);145+test('stderr file path errors should be handled', testFileError, getAbsolutePath, getStderrOption);146+test('stdio[*] file path errors should be handled', testFileError, getAbsolutePath, getStdioOption);147 148 const testFileErrorSync = (t, mapFile, getOptions) => {149 t.throws(() => {150 execaSync('noop.js', getOptions(mapFile('./unknown/file')));5 unmodified lines156 test('stdout file URL errors should be handled - sync', testFileErrorSync, pathToFileURL, getStdoutOption);157 test('stderr file URL errors should be handled - sync', testFileErrorSync, pathToFileURL, getStderrOption);158 test('stdio[*] file URL errors should be handled - sync', testFileErrorSync, pathToFileURL, getStdioOption);159 test('inputFile file path errors should be handled - sync', testFileErrorSync, identity, getInputFileOption);147-test('stdin file path errors should be handled - sync', testFileErrorSync, identity, getStdinOption);148-test('stdout file path errors should be handled - sync', testFileErrorSync, identity, getStdoutOption);149-test('stderr file path errors should be handled - sync', testFileErrorSync, identity, getStderrOption);150-test('stdio[*] file path errors should be handled - sync', testFileErrorSync, identity, getStdioOption);160+test('stdin file path errors should be handled - sync', testFileErrorSync, getAbsolutePath, getStdinOption);161+test('stdout file path errors should be handled - sync', testFileErrorSync, getAbsolutePath, getStdoutOption);162+test('stderr file path errors should be handled - sync', testFileErrorSync, getAbsolutePath, getStderrOption);163+test('stdio[*] file path errors should be handled - sync', testFileErrorSync, getAbsolutePath, getStdioOption);164 165 const testInputFile = async (t, execaMethod) => {166 const inputFile = tempfile();167 await writeFile(inputFile, 'foobar');28 unmodified lines196 const getStringInput = () => ({input: 'foobar'});197 const getBinaryInput = () => ({input: binaryFoobar});198 199 test('input String and inputFile can be both set', testMultipleInputs, [getInputFileOption, getStringInput], execa);187-test('input String and stdin can be both set', testMultipleInputs, [getStdinOption, getStringInput], execa);200+test('input String and stdin can be both set', testMultipleInputs, [getStdinFilePath, getStringInput], execa);201 test('input Uint8Array and inputFile can be both set', testMultipleInputs, [getInputFileOption, getBinaryInput], execa);189-test('input Uint8Array and stdin can be both set', testMultipleInputs, [getStdinOption, getBinaryInput], execa);190-test('stdin and inputFile can be both set', testMultipleInputs, [getStdinOption, getInputFileOption], execa);191-test('input String, stdin and inputFile can be all set', testMultipleInputs, [getInputFileOption, getStdinOption, getStringInput], execa);192-test('input Uint8Array, stdin and inputFile can be all set', testMultipleInputs, [getInputFileOption, getStdinOption, getBinaryInput], execa);202+test('input Uint8Array and stdin can be both set', testMultipleInputs, [getStdinFilePath, getBinaryInput], execa);203+test('stdin and inputFile can be both set', testMultipleInputs, [getStdinFilePath, getInputFileOption], execa);204+test('input String, stdin and inputFile can be all set', testMultipleInputs, [getInputFileOption, getStdinFilePath, getStringInput], execa);205+test('input Uint8Array, stdin and inputFile can be all set', testMultipleInputs, [getInputFileOption, getStdinFilePath, getBinaryInput], execa);206 test('input String and inputFile can be both set - sync', testMultipleInputs, [getInputFileOption, getStringInput], execaSync);194-test('input String and stdin can be both set - sync', testMultipleInputs, [getStdinOption, getStringInput], execaSync);207+test('input String and stdin can be both set - sync', testMultipleInputs, [getStdinFilePath, getStringInput], execaSync);208 test('input Uint8Array and inputFile can be both set - sync', testMultipleInputs, [getInputFileOption, getBinaryInput], execaSync);196-test('input Uint8Array and stdin can be both set - sync', testMultipleInputs, [getStdinOption, getBinaryInput], execaSync);197-test('stdin and inputFile can be both set - sync', testMultipleInputs, [getStdinOption, getInputFileOption], execaSync);198-test('input String, stdin and inputFile can be all set - sync', testMultipleInputs, [getInputFileOption, getStdinOption, getStringInput], execaSync);199-test('input Uint8Array, stdin and inputFile can be all set - sync', testMultipleInputs, [getInputFileOption, getStdinOption, getBinaryInput], execaSync);209+test('input Uint8Array and stdin can be both set - sync', testMultipleInputs, [getStdinFilePath, getBinaryInput], execaSync);210+test('stdin and inputFile can be both set - sync', testMultipleInputs, [getStdinFilePath, getInputFileOption], execaSync);211+test('input String, stdin and inputFile can be all set - sync', testMultipleInputs, [getInputFileOption, getStdinFilePath, getStringInput], execaSync);212+test('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 lines12 | 'ipc'13 | number14 | undefined15 | URL16- | string;16+ | {file: string};17 18 type InputStdioOption =19 | Iterable<string | Uint8Array>20 | AsyncIterable<string | Uint8Array>97 unmodified lines118 - `'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 lines139 - `'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).146 147 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 lines158 - `'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).165 166 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 linesmodified:index.test-d.ts+9 added-9 removed
188 unmodified lines189 expectError(execa('unicorns', {stdin: numberGenerator()}));190 expectError(execa('unicorns', {stdin: [numberGenerator()]}));191 execa('unicorns', {stdin: fileUrl});192 execa('unicorns', {stdin: [fileUrl]});193-execa('unicorns', {stdin: './test'});194-execa('unicorns', {stdin: ['./test']});193+execa('unicorns', {stdin: {file: './test'}});194+execa('unicorns', {stdin: [{file: './test'}]});195 execa('unicorns', {stdin: 1});196 execa('unicorns', {stdin: [1]});197 execa('unicorns', {stdin: undefined});198 execa('unicorns', {stdin: [undefined]});19 unmodified lines218 expectError(execa('unicorns', {stdout: new ReadableStream()}));219 expectError(execa('unicorn', {stdout: [new ReadableStream()]}));220 execa('unicorns', {stdout: fileUrl});221 execa('unicorns', {stdout: [fileUrl]});222-execa('unicorns', {stdout: './test'});223-execa('unicorns', {stdout: ['./test']});222+execa('unicorns', {stdout: {file: './test'}});223+execa('unicorns', {stdout: [{file: './test'}]});224 execa('unicorns', {stdout: 1});225 execa('unicorns', {stdout: [1]});226 execa('unicorns', {stdout: undefined});227 execa('unicorns', {stdout: [undefined]});19 unmodified lines247 expectError(execa('unicorns', {stderr: new ReadableStream()}));248 expectError(execa('unicorns', {stderr: [new ReadableStream()]}));249 execa('unicorns', {stderr: fileUrl});250 execa('unicorns', {stderr: [fileUrl]});251-execa('unicorns', {stderr: './test'});252-execa('unicorns', {stderr: ['./test']});251+execa('unicorns', {stderr: {file: './test'}});252+execa('unicorns', {stderr: [{file: './test'}]});253 execa('unicorns', {stderr: 1});254 execa('unicorns', {stderr: [1]});255 execa('unicorns', {stderr: undefined});256 execa('unicorns', {stderr: [undefined]});13 unmodified lines270 execa('unicorns', {stdio: 'inherit'});271 expectError(execa('unicorns', {stdio: 'ipc'}));272 expectError(execa('unicorns', {stdio: 1}));273 expectError(execa('unicorns', {stdio: fileUrl}));274-expectError(execa('unicorns', {stdio: './test'}));274+expectError(execa('unicorns', {stdio: {file: './test'}}));275 expectError(execa('unicorns', {stdio: new Writable()}));276 expectError(execa('unicorns', {stdio: new Readable()}));277 expectError(execa('unicorns', {stdio: new WritableStream()}));278 expectError(execa('unicorns', {stdio: new ReadableStream()}));22 unmodified lines301 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 lines323 [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 linesmodified:readme.md+3 added-3 removed
581 unmodified lines582 - `'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 lines603 - `'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).610 611 This can be an [array of values](#redirect-stdinstdoutstderr-to-multiple-destinations) such as `['inherit', 'pipe']` or `[filePath, 'pipe']`.10 unmodified lines622 - `'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).629 630 This can be an [array of values](#redirect-stdinstdoutstderr-to-multiple-destinations) such as `['inherit', 'pipe']` or `[filePath, 'pipe']`.297 unmodified lines