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

Function readWorkspaceGlobs

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

Read workspace glob patterns from package.json + pnpm-workspace.yaml.

(projectRoot: string)

Source from the content-addressed store, hash-verified

859
860/** Read workspace glob patterns from package.json + pnpm-workspace.yaml. */
861function readWorkspaceGlobs(projectRoot: string): string[] {
862 const out: string[] = [];
863
864 // package.json `workspaces` (npm / yarn / bun): array, or Yarn's
865 // `{ packages: [...], nohoist: [...] }` object form.
866 try {
867 const pkg = JSON.parse(
868 fs.readFileSync(path.join(projectRoot, 'package.json'), 'utf-8')
869 );
870 const ws = pkg?.workspaces;
871 if (Array.isArray(ws)) {
872 out.push(...ws.filter((w: unknown): w is string => typeof w === 'string'));
873 } else if (ws && Array.isArray(ws.packages)) {
874 out.push(...ws.packages.filter((w: unknown): w is string => typeof w === 'string'));
875 }
876 } catch {
877 /* no / invalid package.json — not a workspace root */
878 }
879
880 // pnpm-workspace.yaml `packages:` list. Parsed with a minimal line
881 // scanner so we don't pull in a YAML dependency.
882 try {
883 const yaml = fs.readFileSync(path.join(projectRoot, 'pnpm-workspace.yaml'), 'utf-8');
884 out.push(...parsePnpmPackages(yaml));
885 } catch {
886 /* no pnpm-workspace.yaml */
887 }
888
889 return out;
890}
891
892/**
893 * Minimal pnpm-workspace.yaml `packages:` extractor. Handles the only shape

Callers 2

loadWithManifestsFunction · 0.85
collectPathDepsFunction · 0.85

Calls 4

parsePnpmPackagesFunction · 0.85
parseMethod · 0.80
pushMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected