* 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)
| 89 | * manifest or field is missing/escaping. |
| 90 | */ |
| 91 | function readOhpmMain(projectRoot: string, dirRel: string): string | null { |
| 92 | let parsed: unknown; |
| 93 | try { |
| 94 | // eslint-disable-next-line @typescript-eslint/no-require-imports |
| 95 | parsed = require('jsonc-parser').parse( |
| 96 | fs.readFileSync(path.join(projectRoot, dirRel, OHPM_MANIFEST), 'utf-8') |
| 97 | ); |
| 98 | } catch { |
| 99 | return null; |
| 100 | } |
| 101 | const main = (parsed as { main?: unknown } | null)?.main; |
| 102 | if (typeof main !== 'string' || !main.trim()) return null; |
| 103 | const entryAbs = path.resolve(projectRoot, dirRel, main.trim()); |
| 104 | const entryRel = path.relative(projectRoot, entryAbs).replace(/\\/g, '/'); |
| 105 | if (entryRel.startsWith('..')) return null; |
| 106 | return entryRel; |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Scan the project for `oh-package.json5` manifests and collect their |
no test coverage detected