* The app a routes file belongs to. An Angular workspace — the directory an * `angular.json` or an Nx `nx.json` sits in — is one app however its routes * are split: angular-spotify declares its screens across a dozen `libs/*` * packages, each with a `src/` of its own, and keyed by those every *
(filePath: string, context: ResolutionContext)
| 674 | * workspace, the conventional app root. |
| 675 | */ |
| 676 | function angularAppRoot(filePath: string, context: ResolutionContext): string { |
| 677 | const source = context.getNodesByKind('route'); |
| 678 | let entry = workspaceRoots.get(context); |
| 679 | if (!entry || entry.source !== source) workspaceRoots.set(context, (entry = { source, memo: new Map() })); |
| 680 | const memo = entry.memo; |
| 681 | const slash = filePath.lastIndexOf('/'); |
| 682 | const dir = slash < 0 ? '' : filePath.slice(0, slash); |
| 683 | let found = memo.get(dir); |
| 684 | if (found === undefined) { |
| 685 | found = null; |
| 686 | for (let d: string | null = dir; d !== null; d = d === '' ? null : d.includes('/') ? d.slice(0, d.lastIndexOf('/')) : '') { |
| 687 | const at = d === '' ? '' : `${d}/`; |
| 688 | if (context.fileExists(`${at}angular.json`) || context.fileExists(`${at}nx.json`)) { |
| 689 | found = at; |
| 690 | break; |
| 691 | } |
| 692 | } |
| 693 | memo.set(dir, found); |
| 694 | } |
| 695 | return found ?? appRootFor(filePath); |
| 696 | } |
| 697 | |
| 698 | export type AngularRouteTable = RootedRouteTable; |
| 699 |
no test coverage detected