Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for double angle bracket >> #1164

Closed
TimCreasman opened this issue Oct 26, 2024 · 5 comments · Fixed by #1166
Closed

Support for double angle bracket >> #1164

TimCreasman opened this issue Oct 26, 2024 · 5 comments · Fixed by #1166

Comments

@TimCreasman
Copy link

Hello!

Apologies if I missed this in the documentation or the closed issues, but is there support for the >> redirection operator?

From my understanding, the single > bracket is essentially supported via the execa({stdout: {file: 'output.txt'}}) syntax but I couldn't find anything referencing >>.

>> is supposed to append the stdout to a file so maybe a syntax like execa({stdout: {append: 'output.txt'}}) would make sense?

@ehmicky
Copy link
Collaborator

ehmicky commented Oct 26, 2024

Hi @TimCreasman,

Execa does not use shells, so it does not use shell-specific syntax like >>. I think you did understand this, but I wanted to clarify, just in case.

That being said, we do try to emulate shell features. In this case, this would be appending to a file.

You can achieve this by doing:

await execa(..., {stdout: [createWriteStream('output.txt', {flags: 'a'}), 'pipe']})

Now, that's a little verbose, so we could maybe add the following syntax instead:

await execa(..., {stdout: {file: 'output.txt', append: true}})

What do you think @sindresorhus?

@TimCreasman
Copy link
Author

@ehmicky

Full disclosure, I did not understand that so thanks for the clarification. I see now this project essentially wraps node's child_process functionality (and if I had read the very first paragraph of this repo I would already have known that haha). I only just started using execa this week having moved from shelljs - loving it so far 👍

And thanks for the example! The second syntax example would be very nice but its good knowing the functionality is already easily available and not crazy verbose.

@sindresorhus
Copy link
Owner

What do you think @sindresorhus?

👍

@ehmicky
Copy link
Collaborator

ehmicky commented Oct 27, 2024

Done at #1166.

@ehmicky
Copy link
Collaborator

ehmicky commented Oct 27, 2024

Published in 9.5.0.

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 a pull request may close this issue.

3 participants