MCPcopy Index your code
hub / github.com/anomalyco/opencode / cleanDirectory

Function cleanDirectory

packages/opencode/src/worktree/index.ts:368–386  ·  view source on GitHub ↗
(target: string)

Source from the content-addressed store, hash-verified

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

Callers 1

index.tsFile · 0.85

Calls 2

errorMessageFunction · 0.90
fromMethod · 0.45

Tested by

no test coverage detected