import { init_esm_shims, __name } from './4RNWLMHM.js';
import { parse } from 'dotenv';
import fs from 'fs';
import path from 'path';

// src/utils.ts
init_esm_shims();
function findParentDirectoryWithFile(dir, filename) {
  let cur = dir;
  while (cur !== "/") {
    const filePath = path.join(cur, filename);
    if (fs.existsSync(filePath)) {
      return {
        directory: cur,
        file: filePath
      };
    }
    cur = path.dirname(cur);
  }
  return null;
}
__name(findParentDirectoryWithFile, "findParentDirectoryWithFile");
function parseVersionFileContents(dir) {
  let out = {};
  let cur = dir;
  while (cur !== "/") {
    const found = findParentDirectoryWithFile(cur, ".versions");
    if (found === null) {
      break;
    }
    cur = path.dirname(found.directory);
    const contents = fs.readFileSync(found.file, "utf-8");
    const parsed = parse(contents);
    out = {
      ...parsed,
      ...out
    };
  }
  return out;
}
__name(parseVersionFileContents, "parseVersionFileContents");

export { findParentDirectoryWithFile, parseVersionFileContents };
//# sourceMappingURL=3CLGGUZ6.js.map
//# sourceMappingURL=3CLGGUZ6.js.map