pastel
pastel copied to clipboard
Is there an exit event / listener?
I ran into an issue where when using useInput
or ink-select-input; pressing ctrl+c
exits the app but not the process.
This is probably because our app has live connections. Is there a way I can subscribe to when the React app exits? I know there's waitUntilExit
but I don't think that's accessible via Pastel (correct me if I'm wrong).
If exitOnCtrlC
was set to false
, I could check for key.ctrl && input === "c"
in the useInput
callback, and then call process.exit(0)
. I've confirmed this by editing the hook in node_modules
. But:
- I want it to disable
exitOnCtrlC
at all. - I don't think it can be disabled via Pastel (#35).
- I shouldn't have to manually handle
ctrl+c
anyway so this isn't a real solution 🤷♂️.
The workaround I'm using right now is to manually listen to stdin via useStdin
. When ctrl+c
is pressed (I've copied the logic from useInput
), I call process.exit(0)
.
The awkward thing is that if any third-party component uses useInput
, a workaround like this has to be used.
I think this is related to #8
@adam-lynch You can simply import and edit the useInput
method (these lines), and handle ctrl-c yourself (call exit()
and process.exit(0)
)
where are you suggesting I do this?