MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / extractConfigFromProgram

Function extractConfigFromProgram

src/lib/prettierFormatter.js:313–334  ·  view source on GitHub ↗
(source)

Source from the content-addressed store, hash-verified

311}
312
313function extractConfigFromProgram(source) {
314 const ast = parseProgram(source);
315 const scope = new Map();
316
317 for (const statement of ast.body) {
318 const declared = readVariableDeclaration(statement, scope);
319 if (declared) {
320 for (const [name, value] of declared) {
321 scope.set(name, value);
322 }
323 continue;
324 }
325
326 const exported = readCommonJsExport(statement, scope);
327 if (exported !== undefined) return exported;
328
329 const esmExported = readEsmExport(statement, scope);
330 if (esmExported !== undefined) return esmExported;
331 }
332
333 return null;
334}
335
336function parseSafeExpression(text) {
337 const wrapped = `(${text})`;

Callers 1

parseJsConfigFunction · 0.85

Calls 5

parseProgramFunction · 0.85
readVariableDeclarationFunction · 0.85
readCommonJsExportFunction · 0.85
readEsmExportFunction · 0.85
setMethod · 0.80

Tested by

no test coverage detected