Inquirer.js
Inquirer.js copied to clipboard
Optionally close session
https://github.com/SBoudrias/Inquirer.js/blob/f14ecd77386edfcb7340c667d804867295cbcfda/packages/inquirer/lib/ui/prompt.js#L66
It would be useful to be able to have nested sessions. Sadly the SIGINT
closing method means this isn't possible, as any BaseUI
that closes will aggressively try and kill the application rather than letting it reach an end.
This is really annoying. As a work around, you can supply stream.PassThrough
streams to inquirer, overriding the .end()
function to prevent the stream from being ended.
const inquirerInput = new PassThrough()
realInput.pipe(inquirerInput)
const inquirerOutput = new PassThrough()
inquirerOutput.pipe(realOutput)
inquirerOutput.end = () => console.log('inquirer tried to end stream')
csont protectedPrompt = inquirer.createPromptModule({input: inquirerInput, output: inquirerOutput})
Hey, I'm happy to review this behavior. Would you be willing to send a PR removing this?
This has been in the codebase a long time, so I honestly don't really remember why it is there... What I can tell you though is that early Node version had awfully broken readline; so that might've been there to make sure it didn't leak or duplicated inputs. It is possible (even likely) this isn't required anymore.
Hi, the new API now exposes this cleanly. Let me know if it helps! https://github.com/SBoudrias/Inquirer.js#canceling-prompt
I'll close this one as the old API is in maintenance mode only now.