realpathSync that never throws (falls back to the input path).
(p: string)
| 97 | |
| 98 | /** realpathSync that never throws (falls back to the input path). */ |
| 99 | function safeRealpath(p: string): string { |
| 100 | try { |
| 101 | return fs.realpathSync(p) |
| 102 | } catch { |
| 103 | return path.resolve(p) |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | /** Walk from cwd up to root, collecting directories (root last). */ |
| 108 | function ancestorDirs(cwd: string): string[] { |