Remove a worktree. Non-fatal on error.
(testName: string)
| 213 | |
| 214 | /** Remove a worktree. Non-fatal on error. */ |
| 215 | cleanup(testName: string): void { |
| 216 | const info = this.active.get(testName); |
| 217 | if (!info) return; |
| 218 | |
| 219 | try { |
| 220 | git(['worktree', 'remove', '--force', info.path], this.repoRoot, true); |
| 221 | } catch { |
| 222 | // Force remove the directory if git worktree remove fails |
| 223 | try { |
| 224 | fs.rmSync(info.path, { recursive: true, force: true }); |
| 225 | git(['worktree', 'prune'], this.repoRoot, true); |
| 226 | } catch { /* non-fatal */ } |
| 227 | } |
| 228 | |
| 229 | this.active.delete(testName); |
| 230 | } |
| 231 | |
| 232 | /** Force-remove all active worktrees (for process exit handler). */ |
| 233 | cleanupAll(): void { |
no test coverage detected