MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / removeDirWithRetries

Function removeDirWithRetries

src/esbuild.mjs:13–29  ·  view source on GitHub ↗
(dirPath, retries = 5, retryDelayMs = 200)

Source from the content-addressed store, hash-verified

11const __dirname = path.dirname(__filename)
12
13async function removeDirWithRetries(dirPath, retries = 5, retryDelayMs = 200) {
14 for (let attempt = 0; attempt <= retries; attempt++) {
15 try {
16 await fs.promises.rm(dirPath, { recursive: true, force: true })
17 return
18 } catch (error) {
19 const isRetryable = error?.code === "ENOTEMPTY" || error?.code === "EBUSY" || error?.code === "EPERM"
20 const isLastAttempt = attempt === retries
21
22 if (!isRetryable || isLastAttempt) {
23 throw error
24 }
25
26 await new Promise((resolve) => globalThis.setTimeout(resolve, retryDelayMs * (attempt + 1)))
27 }
28 }
29}
30
31async function main() {
32 const name = "extension"

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected