* Read an ohpm member's declared entry file: ` /oh-package.json5`'s * `main`, normalized to a projectRoot-relative posix path. Null when the * manifest or field is missing/escaping.
(projectRoot: string, dirRel: string)
| 290 | * manifest or field is missing/escaping. |
| 291 | */ |
| 292 | function readOhpmMain(projectRoot: string, dirRel: string): string | null { |
| 293 | let parsed: unknown; |
| 294 | try { |
| 295 | // eslint-disable-next-line @typescript-eslint/no-require-imports |
| 296 | parsed = require('jsonc-parser').parse( |
| 297 | fs.readFileSync(path.join(projectRoot, dirRel, OHPM_MANIFEST), 'utf-8') |
| 298 | ); |
| 299 | } catch { |
| 300 | return null; |
| 301 | } |
| 302 | const main = (parsed as { main?: unknown } | null)?.main; |
| 303 | if (typeof main !== 'string' || !main.trim()) return null; |
| 304 | const entryAbs = path.resolve(projectRoot, dirRel, main.trim()); |
| 305 | const entryRel = path.relative(projectRoot, entryAbs).replace(/\\/g, '/'); |
| 306 | if (entryRel.startsWith('..')) return null; |
| 307 | return entryRel; |
| 308 | } |
| 309 | |
| 310 | /** |
| 311 | * Scan the project for `oh-package.json5` manifests and collect their |
no test coverage detected