Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

debugger: also exit when the repl emits 'exit' #5637

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions lib/_debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -1540,9 +1540,8 @@ Interface.prototype.repl = function() {
// Don't display any default messages
var listeners = this.repl.rli.listeners('SIGINT').slice(0);
this.repl.rli.removeAllListeners('SIGINT');

// Exit debug repl on Ctrl + C
this.repl.rli.once('SIGINT', function() {

function exitDebugRepl(){
// Restore all listeners
process.nextTick(function() {
listeners.forEach(function(listener) {
Expand All @@ -1552,7 +1551,16 @@ Interface.prototype.repl = function() {

// Exit debug repl
self.exitRepl();
});

self.repl.rli.removeListener('SIGINT', exitDebugRepl);
self.repl.removeListener('exit', exitDebugRepl);
}

// Exit debug repl on Ctrl + C
this.repl.rli.on('SIGINT', exitDebugRepl);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use once() instead of on() so that you don't need to worry about removing the listener?


// Exit debug repl on '.exit'
this.repl.on('exit', exitDebugRepl);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.


// Set new
this.repl.eval = this.debugEval.bind(this);
Expand Down