Created
April 20, 2024 22:21
-
-
Save fzn0x/97e050d4e84293a368e66a4034e1977f to your computer and use it in GitHub Desktop.
Temporary solution for https://github.com/oven-sh/bun/issues/10403 Cannot exit all the processes when CTRL + C in readline, need to enter twice, or enter after CTRL + C.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as readline from "node:readline"; | |
// TODO: remove code when https://github.com/oven-sh/bun/issues/10403 is fixed | |
if (process.stdin.isTTY) { | |
readline.emitKeypressEvents(process.stdin); | |
process.stdin.setRawMode(true); | |
process.stdin.on("keypress", (str, key) => { | |
if (key.ctrl && key.name === "c") process.exit(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment