MCPcopy Index your code
hub / github.com/nodejs/node / createRepl

Function createRepl

lib/internal/repl.js:15–60  ·  view source on GitHub ↗
(env, opts, cb)

Source from the content-addressed store, hash-verified

13module.exports.createInternalRepl = createRepl;
14
15function createRepl(env, opts, cb) {
16 if (typeof opts === 'function') {
17 cb = opts;
18 opts = null;
19 }
20 opts = {
21 [kStandaloneREPL]: true,
22 ignoreUndefined: false,
23 useGlobal: true,
24 breakEvalOnSigint: true,
25 ...opts,
26 };
27
28 if (NumberParseInt(env.NODE_NO_READLINE)) {
29 opts.terminal = false;
30 }
31
32 if (env.NODE_REPL_MODE) {
33 opts.replMode = {
34 'strict': REPL.REPL_MODE_STRICT,
35 'sloppy': REPL.REPL_MODE_SLOPPY,
36 }[env.NODE_REPL_MODE.toLowerCase().trim()];
37 }
38
39 if (opts.replMode === undefined) {
40 opts.replMode = REPL.REPL_MODE_SLOPPY;
41 }
42
43 const size = Number(env.NODE_REPL_HISTORY_SIZE);
44 if (!NumberIsNaN(size) && size > 0) {
45 opts.size = size;
46 } else {
47 opts.size = 1000;
48 }
49
50 const term = 'terminal' in opts ? opts.terminal : process.stdout.isTTY;
51 opts.filePath = term ? env.NODE_REPL_HISTORY : '';
52
53 const repl = REPL.start(opts);
54
55 repl.setupHistory({
56 filePath: opts.filePath,
57 size: opts.size,
58 onHistoryFileLoaded: cb,
59 });
60}

Calls 2

setupHistoryMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…