MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / packageJsonMain

Function packageJsonMain

src/resolution/import-resolver.ts:1431–1439  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

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. */
1431export 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

Callers 2

packageJsonMainOfFunction · 0.90
relativeDirectoryMainFunction · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected