Replies: 2 comments 1 reply
-
My guess is piping Maybe you could filter out the exit signal with a piped stream, and pass that stream to inquirer. Dummy code example, the implementation of the filtering is likely different: const stdin = process.stdin.pipe(ignoreExitSignal);
await input({ ... }, { stdin }); |
Beta Was this translation helpful? Give feedback.
-
There was actually a fairly simple solution, the reopen-tty package provides a cross-platform way to open the tty directly. Then its just a matter of passing a custom input stream to prompt rather than stdin which may be attached to a pipe...
It would be nice if there is a way specify a custom input stream for all prompts rather than passing context to each call. |
Beta Was this translation helpful? Give feedback.
-
I'd like to create a tool that takes input from a pipe and then prompts the user for more input when needed. I haven't found a way to release stdin from the pipe so the prompts works, however. Tried
process.stdin.unpipe()
but that doesn't do the trick.Another idea was to close and reopen stdin to connect it to the tty, but its unclear to me if that's possible in nodejs. Example of what doesn't work below. Any suggestions?
Output is
Beta Was this translation helpful? Give feedback.
All reactions