Nearest candidate walking UP the directory tree from refDir (exclusive).
(candidates: T[], refDir: string)
| 114 | |
| 115 | /** Nearest candidate walking UP the directory tree from refDir (exclusive). */ |
| 116 | function nearestAncestorMatch<T extends { filePath: string }>(candidates: T[], refDir: string): T | null { |
| 117 | for (let dir = parentOf(refDir); dir !== null; dir = parentOf(dir)) { |
| 118 | const inDir = candidates.filter((c) => dirOf(c.filePath) === dir); |
| 119 | if (inDir.length > 0) return inDir[0]!; |
| 120 | } |
| 121 | return null; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Resolve `module.M:<child>` by locating the `module "M"` declaration in the |