(target: string)
| 366 | } |
| 367 | |
| 368 | function cleanDirectory(target: string) { |
| 369 | return Effect.tryPromise({ |
| 370 | try: async () => { |
| 371 | const fsp = await import("fs/promises") |
| 372 | const attempts = process.platform === "win32" ? 50 : 5 |
| 373 | for (const attempt of Array.from({ length: attempts }, (_, i) => i)) { |
| 374 | try { |
| 375 | await fsp.rm(target, { recursive: true, force: true }) |
| 376 | return |
| 377 | } catch (error) { |
| 378 | if (attempt === attempts - 1) throw error |
| 379 | await new Promise((resolve) => setTimeout(resolve, 100)) |
| 380 | } |
| 381 | } |
| 382 | }, |
| 383 | catch: (error) => |
| 384 | new RemoveFailedError({ message: errorMessage(error) || "Failed to remove git worktree directory" }), |
| 385 | }) |
| 386 | } |
| 387 | |
| 388 | const remove = Effect.fn("Worktree.remove")(function* (input: RemoveInput) { |
| 389 | const ctx = yield* InstanceState.context |
no test coverage detected