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

Function readPackageName

src/resolution/workspace-packages.ts:1050–1057  ·  view source on GitHub ↗

Read the `name` field from a member directory's package.json.

(dirAbs: string)

Source from the content-addressed store, hash-verified

1048
1049/** Read the `name` field from a member directory's package.json. */
1050function readPackageName(dirAbs: string): string | null {
1051 try {
1052 const pkg = JSON.parse(fs.readFileSync(path.join(dirAbs, 'package.json'), 'utf-8'));
1053 return typeof pkg?.name === 'string' && pkg.name ? pkg.name : null;
1054 } catch {
1055 return null;
1056 }
1057}

Callers 1

loadWithManifestsFunction · 0.85

Calls 2

parseMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected