| 239 | * change when the reader toggles tests. The repository root is never one. |
| 240 | */ |
| 241 | export function passThroughDirs(paths: Iterable<string>): Set<string> { |
| 242 | const children = new Map<string, Set<string>>(); |
| 243 | const holdsFiles = new Set<string>(); |
| 244 | for (const raw of paths) { |
| 245 | const parts = toPosixPath(raw).split('/').filter(Boolean); |
| 246 | let dir = ''; |
| 247 | for (let i = 0; i < parts.length - 1; i++) { |
| 248 | let kids = children.get(dir); |
| 249 | if (!kids) children.set(dir, (kids = new Set())); |
| 250 | kids.add(parts[i]!); |
| 251 | dir = dir ? `${dir}/${parts[i]}` : parts[i]!; |
| 252 | } |
| 253 | holdsFiles.add(dir); |
| 254 | } |
| 255 | const out = new Set<string>(); |
| 256 | for (const [dir, kids] of children) { |
| 257 | if (dir !== '' && kids.size === 1 && !holdsFiles.has(dir)) out.add(dir); |
| 258 | } |
| 259 | return out; |
| 260 | } |
| 261 | |
| 262 | /** |
| 263 | * Where each level of a file's directory path ends, as indexes into `dirs`: a |