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

Function matchPackage

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

* The package an import names: a path dependency of the nearest manifest * above `fromFile` that declares a matching name, else a workspace member or * a root path dependency. The longest name wins, so `@scope/ui/core` prefers * a `@scope/ui/core` package over a `@scope/ui` one when both exist.

(importPath: string, ws: WorkspacePackages, fromFile?: string)

Source from the content-addressed store, hash-verified

741 * a `@scope/ui/core` package over a `@scope/ui` one when both exist.
742 */
743function matchPackage(importPath: string, ws: WorkspacePackages, fromFile?: string): { name: string; dir: string } | null {
744 const scoped = scopedPackage(importPath, ws, fromFile);
745 if (scoped) return scoped;
746 const name = longestName(importPath, ws.byName.keys());
747 if (name === null) return null;
748 const dir = ws.byName.get(name)!;
749 return fromFile !== undefined && leavesWorkspaceRoot(fromFile, dir, ws) ? null : { name, dir };
750}
751
752/** The nested root (see WorkspacePackages.nestedRoots) `file` is under, the deepest; `''` for the project's own. */
753function workspaceRootOf(file: string, roots: string[]): string {

Callers 2

resolveWorkspaceImportFunction · 0.85
workspaceImportTargetsFunction · 0.85

Calls 4

scopedPackageFunction · 0.85
longestNameFunction · 0.85
leavesWorkspaceRootFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected