(ws: WorkspacePackages, file: string)
| 847 | * files included. |
| 848 | */ |
| 849 | export function workspacePackageDirOf(ws: WorkspacePackages, file: string): string | null { |
| 850 | let dirs = PACKAGE_DIRS.get(ws); |
| 851 | if (!dirs) { |
| 852 | const all = new Set(ws.byName.values()); |
| 853 | for (const names of ws.scopedByName?.values() ?? []) for (const dir of names.values()) all.add(dir); |
| 854 | dirs = [...all].filter((dir) => dir !== '').sort((a, b) => a.length - b.length); |
| 855 | PACKAGE_DIRS.set(ws, dirs); |
| 856 | } |
| 857 | return dirs.find((dir) => file.startsWith(dir + '/')) ?? null; |
| 858 | } |
| 859 | |
| 860 | /** Read workspace glob patterns from package.json + pnpm-workspace.yaml. */ |
| 861 | function readWorkspaceGlobs(projectRoot: string): string[] { |
no test coverage detected