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

debugger: use requireRepl() to load debugger repl #8784

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions lib/_debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ var util = require('util'),
path = require('path'),
net = require('net'),
vm = require('vm'),
repl = require('repl'),
module = require('module'),
repl = module.requireRepl(),
inherits = util.inherits,
assert = require('assert'),
spawn = require('child_process').spawn;
Expand Down Expand Up @@ -774,6 +775,7 @@ function Interface(stdin, stdout, args) {
if (parseInt(process.env['NODE_DISABLE_COLORS'], 10)) {
opts.useColors = false;
}

this.repl = repl.start(opts);

// Do not print useless warning
Expand Down Expand Up @@ -1127,7 +1129,7 @@ Interface.prototype.list = function(delta) {
if (lineno == 1) {
// The first line needs to have the module wrapper filtered out of
// it.
var wrapper = require('module').wrapper[0];
var wrapper = module.wrapper[0];
lines[i] = lines[i].slice(wrapper.length);

client.currentSourceColumn -= wrapper.length;
Expand Down
15 changes: 15 additions & 0 deletions test/simple/test-repl-tab-complete.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,18 @@ testMe.complete(' ', function(error, data) {
testMe.complete('toSt', function(error, data) {
assert.deepEqual(data, [['toString'], 'toSt']);
});

Choose a reason for hiding this comment

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

Do these newly added tests actually test the bug that this PR fixes? It seems these tests don’t involve the debugger, so they seem not to be regression tests for this issue, or am I missing something?

Choose a reason for hiding this comment

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

Ah ok, I hadn't seen the second part of the commit message, sorry.

// Tab complete provides built in libs for require()
putIn.run(['.clear']);

testMe.complete('require(\'', function(error, data) {
assert.strictEqual(error, null);
repl._builtinLibs.forEach(function(lib) {
assert.notStrictEqual(data[0].indexOf(lib), -1, lib + ' not found');
});
});

testMe.complete('require(\'n', function(error, data) {
assert.strictEqual(error, null);
assert.deepEqual(data, [['net'], 'n']);
});