aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Dickinson <christopher.s.dickinson@gmail.com>2015-05-04 01:40:40 -0700
committerChris Dickinson <christopher.s.dickinson@gmail.com>2015-05-04 10:42:42 -0700
commit051d482b151cc15b8273d705ec57209d0fa1db2a (patch)
treefff68d3218bf5c9e276cdf2f91b1d80f02d78b6a /lib
parente67542ae17510e3657c2a946fde3dee4d775ac88 (diff)
downloadandroid-node-v8-051d482b151cc15b8273d705ec57209d0fa1db2a.tar.gz
android-node-v8-051d482b151cc15b8273d705ec57209d0fa1db2a.tar.bz2
android-node-v8-051d482b151cc15b8273d705ec57209d0fa1db2a.zip
repl: fix _debugger by properly proxying repl
The _debugger module uses the internal REPL module, but expects to receive the userland REPL module. This fixes the breakage that occurs by proxying the userland REPL module through the internal module. It also fixes an unintended in-REPL bug, where require(node-module) was not resolving correctly. PR-URL: https://github.com/iojs/io.js/pull/1605 Reviewed-By: Roman Reiss <me@silverwind.io>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/repl.js21
-rw-r--r--lib/repl.js14
2 files changed, 21 insertions, 14 deletions
diff --git a/lib/internal/repl.js b/lib/internal/repl.js
index 5faecae53f..65c3f77ed6 100644
--- a/lib/internal/repl.js
+++ b/lib/internal/repl.js
@@ -1,29 +1,22 @@
'use strict';
-module.exports = {createRepl: createRepl};
-
const Interface = require('readline').Interface;
const REPL = require('repl');
const path = require('path');
+module.exports = Object.create(REPL);
+module.exports.createInternalRepl = createRepl;
+
// XXX(chrisdickinson): The 15ms debounce value is somewhat arbitrary.
// The debounce is to guard against code pasted into the REPL.
const kDebounceHistoryMS = 15;
-try {
- // hack for require.resolve("./relative") to work properly.
- module.filename = path.resolve('repl');
-} catch (e) {
- // path.resolve('repl') fails when the current working directory has been
- // deleted. Fall back to the directory name of the (absolute) executable
- // path. It's not really correct but what are the alternatives?
- const dirname = path.dirname(process.execPath);
- module.filename = path.resolve(dirname, 'repl');
+// XXX(chrisdickinson): hack to make sure that the internal debugger
+// uses the original repl.
+function replStart() {
+ return REPL.start.apply(REPL, arguments);
}
-// hack for repl require to work properly with node_modules folders
-module.paths = require('module')._nodeModulePaths(module.filename);
-
function createRepl(env, cb) {
const opts = {
ignoreUndefined: false,
diff --git a/lib/repl.js b/lib/repl.js
index 95a30c05fc..45bc49b513 100644
--- a/lib/repl.js
+++ b/lib/repl.js
@@ -32,6 +32,20 @@ const Console = require('console').Console;
const domain = require('domain');
const debug = util.debuglog('repl');
+try {
+ // hack for require.resolve("./relative") to work properly.
+ module.filename = path.resolve('repl');
+} catch (e) {
+ // path.resolve('repl') fails when the current working directory has been
+ // deleted. Fall back to the directory name of the (absolute) executable
+ // path. It's not really correct but what are the alternatives?
+ const dirname = path.dirname(process.execPath);
+ module.filename = path.resolve(dirname, 'repl');
+}
+
+// hack for repl require to work properly with node_modules folders
+module.paths = require('module')._nodeModulePaths(module.filename);
+
// If obj.hasOwnProperty has been overridden, then calling
// obj.hasOwnProperty(prop) will break.
// See: https://github.com/joyent/node/issues/1707