Is there any way to trigger a function that’s called when the user types .exit or [Ctrl][D]s the script?
Something like:
repl.start().on('exit', function() {
console.log("Thanks for using customized Node REPL!");
});
(Except, of course, I’d actually put useful code instead of the console.log.)
REPL uses the
Readlinemodule, which emits aCloseevent. From the docs: