mirror of
https://github.com/nodejs/node.git
synced 2025-05-10 05:09:36 +00:00

PR-URL: https://github.com/nodejs/node/pull/43942 Fixes: https://github.com/nodejs/node/issues/40110 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
33 lines
891 B
JavaScript
33 lines
891 B
JavaScript
'use strict';
|
|
|
|
// User passed `-e` or `--eval` arguments to Node without `-i` or
|
|
// `--interactive`.
|
|
|
|
const {
|
|
globalThis,
|
|
} = primordials;
|
|
|
|
const {
|
|
prepareMainThreadExecution
|
|
} = require('internal/bootstrap/pre_execution');
|
|
const { evalModule, evalScript } = require('internal/process/execution');
|
|
const { addBuiltinLibsToObject } = require('internal/modules/cjs/helpers');
|
|
|
|
const { getOptionValue } = require('internal/options');
|
|
|
|
prepareMainThreadExecution();
|
|
addBuiltinLibsToObject(globalThis, '<eval>');
|
|
markBootstrapComplete();
|
|
|
|
const source = getOptionValue('--eval');
|
|
const print = getOptionValue('--print');
|
|
const loadESM = getOptionValue('--import').length > 0;
|
|
if (getOptionValue('--input-type') === 'module')
|
|
evalModule(source, print);
|
|
else
|
|
evalScript('[eval]',
|
|
source,
|
|
getOptionValue('--inspect-brk'),
|
|
print,
|
|
loadESM);
|