#!/usr/bin/env node

// src/utils/fs.ts
import { mkdir, readFile, stat, writeFile } from "fs/promises";
import path from "path";
async function ensureDir(dirPath) {
  await mkdir(dirPath, { recursive: true });
}
async function exists(filePath) {
  try {
    await stat(filePath);
    return true;
  } catch {
    return false;
  }
}
async function readTextFile(filePath) {
  return readFile(filePath, "utf8");
}
async function readTextFileIfExists(filePath) {
  try {
    return await readFile(filePath, "utf8");
  } catch {
    return null;
  }
}
async function writeTextFile(filePath, content) {
  await ensureDir(path.dirname(filePath));
  await writeFile(filePath, content, "utf8");
}
async function readJsonFile(filePath) {
  const data = await readTextFile(filePath);
  return JSON.parse(data);
}
async function writeJsonFile(filePath, data) {
  await writeTextFile(filePath, `${JSON.stringify(data, null, 2)}
`);
}

export {
  ensureDir,
  exists,
  readTextFile,
  readTextFileIfExists,
  writeTextFile,
  readJsonFile,
  writeJsonFile
};
//# sourceMappingURL=chunk-IAYRNVUC.mjs.map