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

Function checkSyntax

lib/internal/main/check_syntax.js:59–77  ·  view source on GitHub ↗
(source, filename)

Source from the content-addressed store, hash-verified

57}
58
59async function checkSyntax(source, filename) {
60 let format;
61 if (filename === '[stdin]' || filename === '[eval]') {
62 format = (getOptionValue('--input-type') === 'module') ? 'module' : 'commonjs';
63 } else {
64 const { defaultResolve } = require('internal/modules/esm/resolve');
65 const { defaultGetFormat } = require('internal/modules/esm/get_format');
66 const { url } = await defaultResolve(pathToFileURL(filename).toString());
67 format = await defaultGetFormat(new URL(url));
68 }
69
70 if (format === 'module') {
71 const { ModuleWrap } = internalBinding('module_wrap');
72 new ModuleWrap(filename, undefined, source, 0, 0);
73 return;
74 }
75
76 wrapSafe(filename, source, undefined, format);
77}

Callers 2

check_syntax.jsFile · 0.85

Calls 7

getOptionValueFunction · 0.85
defaultGetFormatFunction · 0.85
wrapSafeFunction · 0.85
requireFunction · 0.50
defaultResolveFunction · 0.50
pathToFileURLFunction · 0.50
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…