-
-
Notifications
You must be signed in to change notification settings - Fork 629
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
setRawMode fails when running with non-TTY stdin #166
Comments
Thank you! |
What might be good, since it's always nice to have a proper fallback, is to have some way for the app rendered by Ink to determine if In most cases, Ink would just ignore that it can't enable raw mode, but for some cases an app might want to entirely disable an input component. So just doing nothing when |
Yeah, I actually ran into this. I am trying to migrate some tests, where I would I had originally attempted to use pty.js, but may have to give node-pty from the linked thread a shot. That said, it should still work w/o the call to Also happy to PR this as well :). |
@eweilow You don't need Ink for that, see how to check for a tty env: https://stackoverflow.com/questions/20585729/how-to-detect-if-nodes-process-stdout-is-being-piped. |
@vadimdemedes What if |
I was able to solve my problem with node-pty, so I no longer need this. I will just note that components like |
I've started a PR (#172), but realized that it might be useful to throw a nice error by default rather than just ignoring that setRawMode cannot be called. Otherwise this situation would end up with being able to not input anything (which would be confusing!) vadimdemedes/ink-text-input#25 |
Nice, thanks @eweilow! Let's continue discussion there. |
Before the rest of the issue, I must say that Ink is amazing 👍
An issue I've encounted is that when Ink is running in a process where
process.stdin.setRawMode
is undefined (for instance in some CI environments), these lines will throw:https://github.com/vadimdemedes/ink/blob/master/src/components/App.js#L73
https://github.com/vadimdemedes/ink/blob/master/src/components/App.js#L83
This behaviour is detailed by the Node docs on https://nodejs.org/api/tty.html#tty_readstream_setrawmode_mode
After a search for
setRawMode
, it seems that this issue has resurfaced: #40While the easy fix would be to wrap all those calls with a check for
stdin.isTTY
, that might lead to unexpected behaviour when an app actually expects raw mode to have been set!The text was updated successfully, but these errors were encountered: