Skip to content

Allow stdin/stdout/stderr to be an array - #643

Merged
sindresorhus merged 10 commits into
mainfrom
stdio-array
Dec 27, 2023
Merged

sindresorhus merged 10 commits into
mainfrom
stdio-array

Conversation

@ehmicky

@ehmicky ehmicky commented Dec 25, 2023 •

Copy link
Copy Markdown
Collaborator

Fixes #620
Fixes #25

This allows the stdin/stdout/stderr to be an array of values instead of a single one.

Some interesting use cases: "taping" (mentioned in #25):

const { stdout } = await execa(..., { stdout: ['inherit', 'pipe'] })

Or redirecting to both terminal and file:

const { stdout } = await execa(..., { stdout: ['inherit', './path.txt'] })

The way this works is: we pass pipe to child_process.spawn(), and emulate the options ourselves through manual piping.
One caveat (which is documented by this PR): when using inherit + another value, even if the current stdin/stdout/stderr is an interactive TTY, the child process will not be interactive. This contrasts with using inherit on its own.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow stdin/stdout/stderr options to be an array Stdio tap option

2 participants