(parent: string, child: string)
| 26 | * Returns the inclusive directory chain from `parent` to `child`. |
| 27 | */ |
| 28 | export function getDirectoriesBetween(parent: string, child: string): string[] { |
| 29 | const directories = []; |
| 30 | let current = path.resolve(child); |
| 31 | const resolvedParent = path.resolve(parent); |
| 32 | |
| 33 | while (true) { |
| 34 | directories.push(current); |
| 35 | |
| 36 | if (current === resolvedParent) { |
| 37 | return directories.reverse(); |
| 38 | } |
| 39 | |
| 40 | const next = path.dirname(current); |
| 41 | if (next === current) { |
| 42 | return []; |
| 43 | } |
| 44 | |
| 45 | current = next; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Reads stat metadata while distinguishing absent paths from inspection errors. |
no test coverage detected