Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Created September 1, 2019 02:57
Show Gist options
  • Save ELLIOTTCABLE/9b9e3ce207ca64b3220c379406fca1ee to your computer and use it in GitHub Desktop.
Save ELLIOTTCABLE/9b9e3ce207ca64b3220c379406fca1ee to your computer and use it in GitHub Desktop.
// Setting up the terminal, swtiching to the alternate screenbuffer;
term.fullscreen(true)
// Horrible hack to freeze the Node.js event-loop long enough for a user to see output;
function sleep(seconds: number) {
let msecs = seconds * 1000
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, msecs)
}
// Ensuring a clean exit, and a return to the users' expected terminal-state
function onExit() {
sleep(5)
term.fullscreen(false)
}
process.on('exit', onExit)
process.on('SIGINT', onExit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment