import { rm } from "node:fs/promises";

export async function rmRetry(dir: string, retries = 10, delayMs = 500) {
  for (let i = 0; i < retries; i++) {
    try {
      await rm(dir, { force: true, recursive: true });
      return;
    } catch (e) {
      if (i === retries - 1) throw e;
      await new Promise((r) => setTimeout(r, delayMs));
    }
  }
}
