TooTallNate / ttys

Guaranteed read and write streams to the terminal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prompt not closing after taking input from user

vishantsharma opened this issue · comments

I'm running this module in a pre-commit hook. I want some user inputs irrespective of the inputs from the user and commit the code after the user has given the inputs but this is not happening...
The user has to press an extra enter key for the code to be pushed..

Any ideas how to solve this?

commented

@vishantsharma I've encountered a similar issue. Did you ever discover a workaround?

commented

@vishantsharma I resolved the issue of the process hanging by calling the end() method of the returned TTY read stream. As the TTY read stream is a subclass of net.Socket, you need to explicitly call its end() method to have it close.

I found calling ttys.stdin.end() threw an error. But I tried ttys.stdin.destroy() and got the result I wanted. Not sure why -- pinched it from this comment: nodejs/node#22814

PS. Even though I'm running Node 12.10.0.