diff options
Diffstat (limited to 'lib/repl.js')
-rw-r--r-- | lib/repl.js | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/repl.js b/lib/repl.js index 078bb208ae..06703da131 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -42,7 +42,11 @@ 'use strict'; -const internalModule = require('internal/module'); +const { + builtinLibs, + makeRequireFunction, + addBuiltinLibsToObject +} = require('internal/modules/cjs/helpers'); const { processTopLevelAwait } = require('internal/repl/await'); const internalUtil = require('internal/util'); const { isTypedArray } = require('internal/util/types'); @@ -55,7 +59,7 @@ const path = require('path'); const fs = require('fs'); const { Interface } = require('readline'); const { Console } = require('console'); -const Module = require('module'); +const CJSModule = require('internal/modules/cjs/loader'); const domain = require('domain'); const debug = util.debuglog('repl'); const { @@ -96,7 +100,7 @@ try { } // Hack for repl require to work properly with node_modules folders -module.paths = Module._nodeModulePaths(module.filename); +module.paths = CJSModule._nodeModulePaths(module.filename); // If obj.hasOwnProperty has been overridden, then calling // obj.hasOwnProperty(prop) will break. @@ -112,7 +116,7 @@ writer.options = Object.assign({}, util.inspect.defaultOptions, { showProxy: true, depth: 2 }); -exports._builtinLibs = internalModule.builtinLibs; +exports._builtinLibs = builtinLibs; function REPLServer(prompt, stream, @@ -789,14 +793,15 @@ REPLServer.prototype.createContext = function() { } } - var module = new Module('<repl>'); - module.paths = Module._resolveLookupPaths('<repl>', parentModule, true) || []; + var module = new CJSModule('<repl>'); + module.paths = + CJSModule._resolveLookupPaths('<repl>', parentModule, true) || []; - var require = internalModule.makeRequireFunction(module); + var require = makeRequireFunction(module); context.module = module; context.require = require; - internalModule.addBuiltinLibsToObject(context); + addBuiltinLibsToObject(context); return context; }; @@ -1005,7 +1010,7 @@ function complete(line, callback) { } else if (/^\.\.?\//.test(completeOn)) { paths = [process.cwd()]; } else { - paths = module.paths.concat(Module.globalPaths); + paths = module.paths.concat(CJSModule.globalPaths); } for (i = 0; i < paths.length; i++) { |