Created
September 1, 2019 02:57
-
-
Save ELLIOTTCABLE/9b9e3ce207ca64b3220c379406fca1ee to your computer and use it in GitHub Desktop.
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
// 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