(source)
| 311 | } |
| 312 | |
| 313 | function 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 | |
| 336 | function parseSafeExpression(text) { |
| 337 | const wrapped = `(${text})`; |
no test coverage detected