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

Implements stream capture #103

Merged
merged 1 commit into from
Sep 27, 2021
Merged

Implements stream capture #103

merged 1 commit into from
Sep 27, 2021

Conversation

arcanis
Copy link
Owner

@arcanis arcanis commented Sep 26, 2021

It may sound a little weird to have to use this.context.stdout.write to write to the console in a Node context (developers are used to just call console.log for that). While it's important to keep this distinction in order to let commands be chainable (ie one command may call others and capture their output), newest Node releases may provide us an interesting tool to improve the user experience.

This diff introduces a new option, enableCapture. When set (the default is false at the moment), passing non-standard streams to a CLI execution will cause Clipanion to register itself into the process.stdout.write pipeline (same for stderr), effectively capturing everything that JS code would print. Asynchronicity shouldn't be an issue thanks to AsyncLocalStorage, which will ensure that each command access their own streams, even if asynchronous.

@arcanis arcanis merged commit 165c00c into master Sep 27, 2021
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.

None yet

1 participant