forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepl.patch
More file actions
61 lines (61 loc) · 2.7 KB
/
repl.patch
File metadata and controls
61 lines (61 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
diff --git a/lib/repl.js b/lib/repl.js
index 18142862d0..1f6461134e 100644
--- a/lib/repl.js
+++ b/lib/repl.js
@@ -54,9 +54,6 @@ const { commonPrefix, } = require('internal/readline/utils');
const { Console } = require('console');
const { shouldColorize } = require('internal/util/colors');
const CJSModule = require('internal/modules/cjs/loader').Module;
-let _builtinLibs = CJSModule.builtinModules.filter((e) => !e.startsWith('_'));
-const nodeSchemeBuiltinLibs = _builtinLibs.map((lib) => `node:${lib}`);
-BuiltinModule.getSchemeOnlyModuleNames().forEach((lib) => nodeSchemeBuiltinLibs.push(`node:${lib}`));
const domain = require('domain');
let debug = require('internal/util/debuglog').debuglog('repl', (fn) => {
debug = fn;
@@ -79,6 +76,21 @@ let nextREPLResourceNumber = 1;
function getREPLResourceName() {
return `REPL${nextREPLResourceNumber++}`;
}
+
+let nodeSchemeBuiltinLibs
+let _builtinLibs
+function initNodeSchemeLibs() {
+ if (nodeSchemeBuiltinLibs) {
+ return
+ }
+
+ _builtinLibs = CJSModule.builtinModules.filter((e) => !e.startsWith('_'));
+ nodeSchemeBuiltinLibs = _builtinLibs.map((lib) => `node:${lib}`);
+ BuiltinModule.getSchemeOnlyModuleNames().forEach((lib) => nodeSchemeBuiltinLibs.push(`node:${lib}`));
+
+ return
+}
+
// Lazy-loaded.
let processTopLevelAwait;
const globalBuiltins = new Set(vm.runInNewContext('Object.getOwnPropertyNames(globalThis)'));
@@ -1045,6 +1057,7 @@ function completeFSFunctions(match) {
// Warning: This eval's code like "foo.bar.baz", so it will run property
// getter code.
function complete(line, callback) {
+ initNodeSchemeLibs()
// List of completion lists, one for each inheritance "level"
let completionGroups = [];
let completeOn, group;
@@ -1553,14 +1566,14 @@ module.exports = {
};
Object.defineProperty(module.exports, 'builtinModules', {
__proto__: null,
- get: () => _builtinLibs,
+ get: () => (initNodeSchemeLibs(), _builtinLibs),
set: (val) => _builtinLibs = val,
enumerable: true,
configurable: true,
});
Object.defineProperty(module.exports, '_builtinLibs', {
__proto__: null,
- get: pendingDeprecation ? deprecate(() => _builtinLibs, 'repl._builtinLibs is deprecated. Check module.builtinModules instead', 'DEP0142') : () => _builtinLibs,
+ get: pendingDeprecation ? deprecate(() => (initNodeSchemeLibs(), _builtinLibs), 'repl._builtinLibs is deprecated. Check module.builtinModules instead', 'DEP0142') : () => (initNodeSchemeLibs(), _builtinLibs),
set: pendingDeprecation ? deprecate((val) => _builtinLibs = val, 'repl._builtinLibs is deprecated. Check module.builtinModules instead', 'DEP0142') : (val) => _builtinLibs = val,
enumerable: false,
configurable: true,