MCPcopy Create free account
hub / github.com/dmno-dev/bumpy / getWorkspaceGlobs

Function getWorkspaceGlobs

packages/bumpy/src/utils/package-manager.ts:47–73  ·  view source on GitHub ↗
(rootDir: string, pm: PackageManager)

Source from the content-addressed store, hash-verified

45}
46
47async function getWorkspaceGlobs(rootDir: string, pm: PackageManager): Promise<string[]> {
48 // pnpm uses pnpm-workspace.yaml
49 if (pm === 'pnpm') {
50 const wsFile = resolve(rootDir, 'pnpm-workspace.yaml');
51 if (await exists(wsFile)) {
52 const content = await readText(wsFile);
53 const parsed = yaml.load(content) as { packages?: string[] } | null;
54 if (parsed?.packages) return parsed.packages;
55 }
56 }
57
58 // npm, yarn, bun all use "workspaces" in package.json
59 try {
60 const pkg = await readJson<Record<string, unknown>>(resolve(rootDir, 'package.json'));
61 const workspaces = pkg.workspaces;
62 if (Array.isArray(workspaces)) return workspaces as string[];
63 // Yarn supports { packages: [...] } format
64 if (workspaces && typeof workspaces === 'object' && 'packages' in workspaces) {
65 const pkgs = (workspaces as { packages: string[] }).packages;
66 if (Array.isArray(pkgs)) return pkgs;
67 }
68 } catch {
69 // ignore
70 }
71
72 return [];
73}
74
75/**
76 * Files that may contain catalog definitions, in the order they're applied.

Callers 1

detectWorkspacesFunction · 0.85

Calls 2

existsFunction · 0.90
readTextFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…