node/lib/internal/main/eval_string.js
XadillaX c7222b3589 lib,repl: ignore non-canBeRequiredByUsers built-in
e.g. `wasi` under no `--experimental-wasi-unstable-preview1` flag
shouldn't be pre-required.

PR-URL: https://github.com/nodejs/node/pull/39942
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
2021-09-07 10:51:56 +08:00

31 lines
814 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');
if (getOptionValue('--input-type') === 'module')
evalModule(source, print);
else
evalScript('[eval]',
source,
getOptionValue('--inspect-brk'),
print);