'use strict';

var VO65XOWD_cjs = require('./VO65XOWD.cjs');
var dotenv = require('dotenv');
var fs = require('fs');
var path = require('path');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var fs__default = /*#__PURE__*/_interopDefault(fs);
var path__default = /*#__PURE__*/_interopDefault(path);

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

exports.findParentDirectoryWithFile = findParentDirectoryWithFile;
exports.parseVersionFileContents = parseVersionFileContents;
//# sourceMappingURL=5RAWDGJY.cjs.map
//# sourceMappingURL=5RAWDGJY.cjs.map