(fn)
| 21 | } |
| 22 | |
| 23 | function withRmRetry(fn) { |
| 24 | for (let attempt = 0; attempt <= 3; attempt += 1) { |
| 25 | try { |
| 26 | fn(); |
| 27 | return; |
| 28 | } catch (err) { |
| 29 | if (err?.code === 'ENOENT') return; |
| 30 | if (!['EBUSY', 'ENOTEMPTY', 'EPERM'].includes(err?.code) || attempt === 3) { |
| 31 | throw err; |
| 32 | } |
| 33 | sleepSync(50 * (attempt + 1)); |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | function rm(target) { |
| 39 | const pending = [target]; |