9b0dff45 days ago10 lines · 302 B| 1 | /** "src/a/b.ts" -> ["src/a/b.ts", "src/a", "src", ""] */ |
| 2 | export function ancestorsOf(path: string) { |
| 3 | const segments = path.split('/'); |
| 4 | const paths: string[] = []; |
| 5 | for (let i = segments.length; i > 0; i--) { |
| 6 | paths.push(segments.slice(0, i).join('/')); |
| 7 | } |
| 8 | paths.push(''); |
| 9 | return paths; |
| 10 | } |