summaryrefslogtreecommitdiff
path: root/deps/node-inspect/lib/internal/inspect_repl.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/node-inspect/lib/internal/inspect_repl.js')
-rw-r--r--deps/node-inspect/lib/internal/inspect_repl.js30
1 files changed, 17 insertions, 13 deletions
diff --git a/deps/node-inspect/lib/internal/inspect_repl.js b/deps/node-inspect/lib/internal/inspect_repl.js
index 38fe4684cf..d9d3f89f03 100644
--- a/deps/node-inspect/lib/internal/inspect_repl.js
+++ b/deps/node-inspect/lib/internal/inspect_repl.js
@@ -25,6 +25,7 @@ const Path = require('path');
const Repl = require('repl');
const util = require('util');
const vm = require('vm');
+const fileURLToPath = require('url').fileURLToPath;
const debuglog = util.debuglog('inspect');
@@ -89,9 +90,12 @@ function isNativeUrl(url) {
return url.replace('.js', '') in NATIVES || url === 'bootstrap_node.js';
}
-function getRelativePath(filename) {
+function getRelativePath(filenameOrURL) {
const dir = Path.join(Path.resolve(), 'x').slice(0, -1);
+ const filename = filenameOrURL.startsWith('file://') ?
+ fileURLToPath(filenameOrURL) : filenameOrURL;
+
// Change path to relative, if possible
if (filename.indexOf(dir) === 0) {
return filename.slice(dir.length);
@@ -958,8 +962,8 @@ function createRepl(inspector) {
get repl() {
// Don't display any default messages
- const listeners = repl.rli.listeners('SIGINT').slice(0);
- repl.rli.removeAllListeners('SIGINT');
+ const listeners = repl.listeners('SIGINT').slice(0);
+ repl.removeAllListeners('SIGINT');
const oldContext = repl.context;
@@ -967,7 +971,7 @@ function createRepl(inspector) {
// Restore all listeners
process.nextTick(() => {
listeners.forEach((listener) => {
- repl.rli.on('SIGINT', listener);
+ repl.on('SIGINT', listener);
});
});
@@ -975,21 +979,21 @@ function createRepl(inspector) {
repl.eval = controlEval;
// Swap history
- history.debug = repl.rli.history;
- repl.rli.history = history.control;
+ history.debug = repl.history;
+ repl.history = history.control;
repl.context = oldContext;
- repl.rli.setPrompt('debug> ');
+ repl.setPrompt('debug> ');
repl.displayPrompt();
- repl.rli.removeListener('SIGINT', exitDebugRepl);
+ repl.removeListener('SIGINT', exitDebugRepl);
repl.removeListener('exit', exitDebugRepl);
exitDebugRepl = null;
};
// Exit debug repl on SIGINT
- repl.rli.on('SIGINT', exitDebugRepl);
+ repl.on('SIGINT', exitDebugRepl);
// Exit debug repl on repl exit
repl.on('exit', exitDebugRepl);
@@ -999,10 +1003,10 @@ function createRepl(inspector) {
repl.context = {};
// Swap history
- history.control = repl.rli.history;
- repl.rli.history = history.debug;
+ history.control = repl.history;
+ repl.history = history.debug;
- repl.rli.setPrompt('> ');
+ repl.setPrompt('> ');
print('Press Ctrl + C to leave debug repl');
repl.displayPrompt();
@@ -1077,7 +1081,7 @@ function createRepl(inspector) {
repl.defineCommand('interrupt', () => {
// We want this for testing purposes where sending CTRL-C can be tricky.
- repl.rli.emit('SIGINT');
+ repl.emit('SIGINT');
});
// Init once for the initial connection