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

Function evalScript

lib/internal/process/execution.js:83–107  ·  view source on GitHub ↗
(name, body, breakFirstLine, print, shouldLoadESM = false)

Source from the content-addressed store, hash-verified

81}
82
83function evalScript(name, body, breakFirstLine, print, shouldLoadESM = false) {
84 const origModule = globalThis.module; // Set e.g. when called from the REPL.
85 const module = createModule(name);
86 const baseUrl = pathToFileURL(module.filename).href;
87
88 if (shouldUseModuleEntryPoint(name, body)) {
89 return getOptionValue('--strip-types') ?
90 evalTypeScriptModuleEntryPoint(body, print) :
91 evalModuleEntryPoint(body, print);
92 }
93
94 const evalFunction = () => runScriptInContext(name,
95 body,
96 breakFirstLine,
97 print,
98 module,
99 baseUrl,
100 undefined,
101 origModule);
102
103 if (shouldLoadESM) {
104 return require('internal/modules/run_main').runEntryPointWithESMLoader(evalFunction);
105 }
106 evalFunction();
107}
108
109const exceptionHandlerState = {
110 captureFn: null, // Primary callback (for domain's exclusive use)

Callers 2

repl.jsFile · 0.50

Calls 8

getOptionValueFunction · 0.85
evalModuleEntryPointFunction · 0.85
evalFunctionFunction · 0.85
createModuleFunction · 0.70
pathToFileURLFunction · 0.50
requireFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…