-
-
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
Fix setRawMode with non-TTY stdin and expose isRawModeSupported on StdinContext #172
Fix setRawMode with non-TTY stdin and expose isRawModeSupported on StdinContext #172
Conversation
Everything looks good to me! Considering that you've added |
Yeah, I agree.
The behaviour now is also that |
e25a395
to
9ba9083
Compare
Don't forget to unmark this PR as draft when you think it's ready ;) |
The code changes are ready, but I'm not comfortable with the tests yet (I've not been able to properly run the fixtures on Windows). Going to try and wrap it up with a Mac tomorrow afternoon :) |
Hey @eweilow, how's it going? If you don't have the time, that's ok, just let me know ;) |
f1b446e
to
cad42c3
Compare
I think it's ready, but the tests aren't perfect (I would have liked to have done more thorough testing of App, but I can't figure out how to do it 😢 - I'm too stuck in how Jest works). The ones I've written appear to pass on my machine, so that's something! |
It uses Ava, not Jest :) What were you struggling with in tests? |
Ah yes, what I meant to say is that I'm too used to Jest 👍 What I also wanted to do was something like this, but it ended up troublesome because App required to be exported (which affects the public API): test('isRawModeSupported should return correctly', t => {
t.true(App.prototype.isRawModeSupported({ isTTY: true }));
t.false(App.prototype.isRawModeSupported({ isTTY: false }));
}); It also feels wrong to use |
You can test that by overriding |
Sorry for the delay. I've had to focus my attention writing on my degree project report. Regarding #172 (comment) - it is tested by the two component tests implemented right now. But this essentially boils down to preference, where you'll have the final say. |
No worries, this is open source :)
I don't think I understand why it has to be a isRawModeSupported() {
return this.props.stdin.isTTY;
} |
Sure, it's now reverted to that. |
Looking great, sorry for late reply! I will make some tiny adjustments (mostly naming) and merge it. Thank you! |
Great work, @eweilow, this is very useful! |
Out in |
Awesome 👍 Now I can remove the TTY workaround I had to implement 💃 |
After vadimdemedes/ink#172 was merged, Ink's Inputs renders differently when in TTY mode. Without this change, there is no output in `lastFrame` from Input elements.
This should probably have been considered a breaking change, as throwing here breaks the expected semantics of the function. You've introduced new, unexpected behavior where it worked previously. I updated |
Calling My reasoning for not silently ignoring is that a component might want to not provide input at all if running in something like a CI environment (while still being able to use Ink). Ignoring a call to In your PR vadimdemedes/ink-testing-library#7 I see that you updated the incomplete mock of https://nodejs.org/api/tty.html#tty_class_tty_readstream (which before your PR excludes the isTTY property). For a normal application (that passes a real tty.ReadStream to |
Do I understand correctly: besides |
That's the idea. If The function after this PR just does slightly stricter checking for when to throw and throws a nicer error. |
I agree with @eweilow, as this was technically a bug in Ink. Ink shouldn't have allowed enabling raw mode where it's unsupported, because it will crash the process. |
After vadimdemedes/ink#172 was merged, Ink's Inputs renders differently when in TTY mode. Without this change, there is no output in `lastFrame` from Input elements.
This pull request tries to implement the fixes discussed in #166
There are not yet any tests, as I'd like to get feedback on whether this is the route to go 👍
A thing that is concerning is that it would be nice to have useful errors for the situation in vadimdemedes/ink-text-input#25, while an application that supports running in CI might want to just ignore setRawMode.
Todo