-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Redirect Output #519
Comments
@brianantonelli I needed this too and just discovered it's already available. const inquirer = require('inquirer')
const prompt = inquirer.createPromptModule({ output: process.stderr })
prompt(/* question array/object here */) |
@jrylan thanks for following up with the proper way to handle it <3 |
Thx! |
So I'm still seeing some issues with this. I followed @jrylan 's instructions and my prompts are now directed to
|
@brianantonelli That's strange, is that on AWS? I'm using iTerm2 as my terminal on macOS and all the output is identical when using |
No, running this on OSX in Terminal. As soon as I make the call to inquirer I get those control chars. The one at the end really throws me because its printing that many function calls later. I only see these characters in VIM. I caught this because it breaks wrapping the output in a |
@brianantonelli weird, but that doesn't seem relate to Inquirer. As you might guess, we're not snooping in on your AWS creds. |
That's just an example output from an application that leverages this library. In my application if I pipe all data to stderr using the above solution and only do a single output to stdout (the AWS keys export command in this case) I see these control characters. If I remove the call to inquirer the control chars disappear. |
@brianantonelli I'm not super familiar with that, but any chance some ANSI control chars can't be use on stderr? |
This only occurs if you use the list prompt. If I do a standard input prompt the characters aren't there. Here's a snippet to reproduce this:
|
Any ideas? |
@brianantonelli Those control codes are for colours. This is something inquirer uses. Vi doesn't support those control code colours, so displays the base codes. Hence you're running into an issue. |
Can't those be disabled? |
@brianantonelli You can use something like strip-ansi to remove ansi from a string, I've opened an issue to be able to use it with streams jlord/sheetsee.js#26. However, it would probably be pretty simple to allow it to support streams yourself. It's been a while since I've manipulated such streams, but with a stream.Transform it should work. |
Simpler yet, I believe chalk doesn't print colors when |
Would love to see a configuration option to redirect output to
stderr
instead ofstdout
. That way programs could support functionality like:Then we could then display the prompt through
stderr
so that only the response will be evaluated.The text was updated successfully, but these errors were encountered: