diff --git a/docs/api.md b/docs/api.md index a5de03ec23..5da22baa73 100644 --- a/docs/api.md +++ b/docs/api.md @@ -759,6 +759,9 @@ _Type:_ `object` This lists all options for [`execa()`](#execafile-arguments-options) and the [other methods](#methods). +> [!IMPORTANT] Differences from `child_process.spawn` API +> - `stdio: [..., 'ipc']` is deprecated and will produce a runtime error in version 10 + The following options [can specify different values](output.md#stdoutstderr-specific-options) for [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr): [`verbose`](#optionsverbose), [`lines`](#optionslines), [`stripFinalNewline`](#optionsstripfinalnewline), [`buffer`](#optionsbuffer), [`maxBuffer`](#optionsmaxbuffer). ### options.preferLocal @@ -865,6 +868,10 @@ Write some input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Stan See also the [`inputFile`](#optionsinputfile) and [`stdin`](#optionsstdin) options. +> [!NOTE] +> Be careful when combining `input` with `stdin: 'inherit'` or `stdio: 'inherit'`; +> See [this section](input.md#combining-input-with-stdin-inherit) for details. + [More info.](input.md#string-input) ### options.inputFile @@ -877,6 +884,10 @@ See also the [`input`](#optionsinput) and [`stdin`](#optionsstdin) options. [More info.](input.md#file-input) +> [!NOTE] +> Be careful when combining `inputFile` with `stdin: 'inherit'` or `stdio: 'inherit'`; +> See [this section](input.md#combining-input-with-stdin-inherit) for details. + ### options.stdin _TypeScript:_ [`StdinOption`](typescript.md) or [`StdinSyncOption`](typescript.md)\ @@ -925,6 +936,9 @@ A single string can be used [as a shortcut](output.md#shortcut). The array can have more than 3 items, to create [additional file descriptors](output.md#additional-file-descriptors) beyond [`stdin`](#optionsstdin)/[`stdout`](#optionsstdout)/[`stderr`](#optionsstderr). +> [!IMPORTANT] Differences from `child_process.spawn` API +> - `stdio: [..., 'ipc']` is deprecated and will produce a runtime error in version 10 + More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md). ### options.all diff --git a/docs/input.md b/docs/input.md index 5d24c3f209..9563093f20 100644 --- a/docs/input.md +++ b/docs/input.md @@ -58,6 +58,10 @@ If the input is already available as a string, it can be passed directly to the await execa({input: 'stdinInput'})`npm run scaffold`; ``` +> [!NOTE] +> Be careful when combining `input` with `stdin: 'inherit'` or `stdio: 'inherit'`; +> See [this section](#combining-input-with-stdin-inherit) for details. + The [`stdin`](api.md#optionsstdin) option can also be used, although the string must be wrapped in two arrays for [syntax reasons](output.md#multiple-targets). ```js @@ -82,6 +86,10 @@ await execa({stdin: {file: 'input.txt'}})`npm run scaffold`; await execa({stdin: new URL('file:///path/to/input.txt')})`npm run scaffold`; ``` +> [!NOTE] +> Be careful when combining `inputFile` with `stdin: 'inherit'` or `stdio: 'inherit'`; +> See [this section](#combining-input-with-stdin-inherit) for details. + ## Terminal input The parent process' input can be re-used in the subprocess by passing `'inherit'`. This is especially useful to receive interactive input in command line applications. @@ -90,6 +98,10 @@ The parent process' input can be re-used in the subprocess by passing `'inherit' await execa({stdin: 'inherit'})`npm run scaffold`; ``` +> [!NOTE] +> Be careful when combining `input` with `stdin: 'inherit'` or `stdio: 'inherit'`; +> See [this section](#combining-input-with-stdin-inherit) for details. + ## Any input type If the subprocess [uses Node.js](node.md), [almost any type](ipc.md#message-type) can be passed to the subprocess using the [`ipcInput`](ipc.md#send-an-initial-message) option. The subprocess retrieves that input using [`getOneMessage()`](api.md#getonemessagegetonemessageoptions). @@ -114,6 +126,9 @@ const ipcInput = await getOneMessage(); ## Additional file descriptors +> [!IMPORTANT] Differences from `child_process.spawn` API +> - `stdio: [..., 'ipc']` is deprecated and will produce a runtime error in version 10 + The [`stdio`](api.md#optionsstdio) option can be used to pass some input to any [file descriptor](https://en.wikipedia.org/wiki/File_descriptor), as opposed to only [`stdin`](api.md#optionsstdin). ```js @@ -123,6 +138,19 @@ await execa({ })`npm run build`; ``` +## Combining `input` with `stdin: 'inherit'` + +> [!WARNING] +> If `input` and `stdin: 'inherit'` (or `stdio: 'inherit'` or `stdio: ['inherit', ...]`) are combined, +> the child will not inherit the parent's `stdin` and `execa` will pipe both `input` and the parent's +> `stdin` to the child's `stdin`. +> +> Therefore the child's `stdin` will not be a TTY and will not close before the parent's `process.stdin` +> in this case. +> +> Version 10 will drop the behavior of piping the parent's `process.stdin` to the child, hence its `stdin` +> will close once `input` has been piped. +
[**Next**: 📢 Output](output.md)\