import { promises } from 'node:fs';
import { c as consola } from './cli.61828232.mjs';

const overrideEnv = (targetEnv) => {
  const currentEnv = process.env.NODE_ENV;
  if (currentEnv && currentEnv !== targetEnv) {
    console.warn(
      `Changing \`NODE_ENV\` from \`${currentEnv}\` to \`${targetEnv}\`, to avoid unintended behavior.`
    );
  }
  process.env.NODE_ENV = targetEnv;
};

async function clearDir(path) {
  await promises.rm(path, { recursive: true, force: true });
  await promises.mkdir(path, { recursive: true });
}
async function rmRecursive(paths) {
  await Promise.all(
    paths.filter((p) => typeof p === "string").map(async (path) => {
      consola.debug("Removing recursive path", path);
      await promises.rm(path, { recursive: true, force: true }).catch(() => {
      });
    })
  );
}

export { clearDir as c, overrideEnv as o, rmRecursive as r };
