node/lib/internal/main/repl.js
Joyee Cheung 09a5f0252e
process: move deprecation warning initialization into pre_execution.js
Since this is only necessary when user code execution is expected.

PR-URL: https://github.com/nodejs/node/pull/25825
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-08 08:08:48 +08:00

47 lines
1.0 KiB
JavaScript

'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 {
initializeDeprecations,
initializeClusterIPC,
initializePolicy,
initializeESMLoader,
loadPreloadModules
} = require('internal/bootstrap/pre_execution');
const {
evalScript
} = require('internal/process/execution');
initializeDeprecations();
initializeClusterIPC();
initializePolicy();
initializeESMLoader();
loadPreloadModules();
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();