autoheal
Version:
GPT Test driven development. Automatically fix tests and guide GPT to write and fix code using your tests.
22 lines (21 loc) • 700 B
JavaScript
import * as readline from "readline";
// Set raw mode for process.stdin
if (process.stdin.isTTY) {
process.stdin.setRawMode(true);
}
// Disable output of the process.stdin
readline.emitKeypressEvents(process.stdin, { ctrl: true, meta: true });
// Start listening to the keypress events
process.stdin.on("keypress", (str, key) => {
// Check if the key pressed is 'escape'
if (key.sequence === "\u001b") {
console.log("Escape key pressed!");
// Restore the process.stdin settings and exit the process
if (process.stdin.isTTY) {
process.stdin.setRawMode(false);
}
process.exit(0);
}
});
// Resume process.stdin
process.stdin.resume();