MCPcopy
hub / github.com/colbymchenry/codegraph / loadWorkspacePackages

Function loadWorkspacePackages

src/resolution/workspace-packages.ts:45–61  ·  view source on GitHub ↗
(projectRoot: string)

Source from the content-addressed store, hash-verified

43 * the same way it does {@link loadProjectAliases} / {@link loadGoModule}.
44 */
45export function loadWorkspacePackages(projectRoot: string): WorkspacePackages | null {
46 const patterns = readWorkspaceGlobs(projectRoot);
47 if (patterns.length === 0) return null;
48
49 const byName = new Map<string, string>();
50 for (const pattern of patterns) {
51 for (const dir of expandWorkspaceGlob(projectRoot, pattern)) {
52 const pkgName = readPackageName(path.join(projectRoot, dir));
53 // First declaration wins — workspace patterns are tried in order.
54 if (pkgName && !byName.has(pkgName)) byName.set(pkgName, dir);
55 }
56 }
57 if (byName.size === 0) return null;
58
59 logDebug('workspace packages loaded', { count: byName.size });
60 return { byName };
61}
62
63/**
64 * Rewrite a bare workspace import to a path relative to projectRoot,

Callers 1

createContextMethod · 0.90

Calls 7

logDebugFunction · 0.90
readWorkspaceGlobsFunction · 0.85
expandWorkspaceGlobFunction · 0.85
readPackageNameFunction · 0.85
joinMethod · 0.80
hasMethod · 0.80
setMethod · 0.80

Tested by

no test coverage detected