(text: string)
| 1429 | |
| 1430 | /** A `package.json`'s `main`, trimmed; null when it has none or doesn't parse. A leading byte-order mark is skipped, as Node skips it. */ |
| 1431 | export function packageJsonMain(text: string): string | null { |
| 1432 | let main: unknown; |
| 1433 | try { |
| 1434 | main = (JSON.parse(text.replace(/^\uFEFF/, '')) as { main?: unknown } | null)?.main; |
| 1435 | } catch { |
| 1436 | return null; |
| 1437 | } |
| 1438 | return typeof main === 'string' && main.trim() ? main.trim() : null; |
| 1439 | } |
| 1440 | |
| 1441 | /** |
| 1442 | * The indexed file a directory's `package.json` names as `main`: fastify's |
no test coverage detected