diff options
author | Chris Dickinson <christopher.s.dickinson@gmail.com> | 2015-04-23 00:35:53 -0700 |
---|---|---|
committer | Chris Dickinson <christopher.s.dickinson@gmail.com> | 2015-04-30 19:33:05 -0700 |
commit | 0450ce7db22ab4b6f9b2119197389ed7d3eac8c3 (patch) | |
tree | 9f9c8444e4370af50a0fa4216fbfa825a737eb0d /lib/module.js | |
parent | a5dcff827a2c7eaec9c20b6271bead8d2225c7c8 (diff) | |
download | android-node-v8-0450ce7db22ab4b6f9b2119197389ed7d3eac8c3.tar.gz android-node-v8-0450ce7db22ab4b6f9b2119197389ed7d3eac8c3.tar.bz2 android-node-v8-0450ce7db22ab4b6f9b2119197389ed7d3eac8c3.zip |
repl: add mode detection, cli persistent history
this creates a new internal module responsible for providing
the repl created via "iojs" or "iojs -i," and adds the following
options to the readline and repl subsystems:
* "repl mode" - determine whether a repl is strict mode, sloppy mode,
or auto-detect mode.
* historySize - determine the maximum number of lines a repl will store
as history.
The built-in repl gains persistent history support when the
NODE_REPL_HISTORY_FILE environment variable is set. This functionality
is not exposed to userland repl instances.
PR-URL: https://github.com/iojs/io.js/pull/1513
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'lib/module.js')
-rw-r--r-- | lib/module.js | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/module.js b/lib/module.js index eba3de8171..515ab6789c 100644 --- a/lib/module.js +++ b/lib/module.js @@ -273,6 +273,17 @@ Module._load = function(request, parent, isMain) { debug('Module._load REQUEST ' + (request) + ' parent: ' + parent.id); } + // REPL is a special case, because it needs the real require. + if (request === 'internal/repl' || request === 'repl') { + if (Module._cache[request]) { + return Module._cache[request]; + } + var replModule = new Module(request); + replModule._compile(NativeModule.getSource(request), `${request}.js`); + NativeModule._cache[request] = replModule; + return replModule.exports; + } + var filename = Module._resolveFilename(request, parent); var cachedModule = Module._cache[filename]; @@ -281,14 +292,6 @@ Module._load = function(request, parent, isMain) { } if (NativeModule.nonInternalExists(filename)) { - // REPL is a special case, because it needs the real require. - if (filename == 'repl') { - var replModule = new Module('repl'); - replModule._compile(NativeModule.getSource('repl'), 'repl.js'); - NativeModule._cache.repl = replModule; - return replModule.exports; - } - debug('load native module ' + request); return NativeModule.require(filename); } @@ -502,7 +505,7 @@ Module._initPaths = function() { // bootstrap repl Module.requireRepl = function() { - return Module._load('repl', '.'); + return Module._load('internal/repl', '.'); }; Module._initPaths(); |