| 280 | } |
| 281 | |
| 282 | async function removePath(fs: RemoveFsClient, abs: string): Promise<void> { |
| 283 | if (typeof fs.promises.rm === "function") { |
| 284 | await fs.promises.rm(abs, { recursive: true, force: true }); |
| 285 | return; |
| 286 | } |
| 287 | // Fallback for fs implementations without `rm`: try unlink, |
| 288 | // then a recursive rmdir. |
| 289 | try { |
| 290 | await fs.promises.unlink(abs); |
| 291 | } catch { |
| 292 | if (typeof fs.promises.rmdir === "function") { |
| 293 | await fs.promises.rmdir(abs, { recursive: true }); |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | function ancestorDirs(path: string): string[] { |
| 299 | const out: string[] = []; |