import { config } from "dotenv";
import { existsSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";

const rootDir = resolve(dirname(fileURLToPath(import.meta.url)), "..");

for (const envPath of [
  resolve(rootDir, ".env"),
  resolve(rootDir, "../clarizen-lib/.env"),
]) {
  if (existsSync(envPath)) {
    config({ path: envPath });
    break;
  }
}
