* 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)
| 741 | * a `@scope/ui/core` package over a `@scope/ui` one when both exist. |
| 742 | */ |
| 743 | function 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. */ |
| 753 | function workspaceRootOf(file: string, roots: string[]): string { |
no test coverage detected