blob: c2bf54f8bb698105def4c142dcba13117ed23726 (
plain)
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
|
'use strict';
// Create the REPL if `-i` or `--interactive` is passed, or if
// the main module is not specified and stdin is a TTY.
const {
prepareMainThreadExecution
} = require('internal/bootstrap/pre_execution');
const {
evalScript
} = require('internal/process/execution');
prepareMainThreadExecution();
// --entry-type flag not supported in REPL
if (require('internal/options').getOptionValue('--entry-type')) {
console.error('Cannot specify --entry-type for REPL');
process.exit(1);
}
const cliRepl = require('internal/repl');
cliRepl.createInternalRepl(process.env, (err, repl) => {
if (err) {
throw err;
}
repl.on('exit', () => {
if (repl._flushing) {
repl.pause();
return repl.once('flushHistory', () => {
process.exit();
});
}
process.exit();
});
});
// If user passed '-e' or '--eval' along with `-i` or `--interactive`,
// evaluate the code in the current context.
if (process._eval != null) {
evalScript('[eval]', process._eval, process._breakFirstLine);
}
markBootstrapComplete();
|