'use strict';

var _4BP4CCPZ_cjs = require('./4BP4CCPZ.cjs');
var KHVGLVR5_cjs = require('./KHVGLVR5.cjs');
var promises = require('fs/promises');
var path = require('path');

// src/utils.ts
KHVGLVR5_cjs.init_cjs_shims();
var rootFiles = [
  "pnpm-workspace.yaml",
  ".git"
];
var getCombinationId = /* @__PURE__ */ KHVGLVR5_cjs.__name((context, combination) => Object.entries(_4BP4CCPZ_cjs.findToolVersionsForCombination(context, combination)).toSorted().flat().join("-"), "getCombinationId");
var findFileInParentDirectory = /* @__PURE__ */ KHVGLVR5_cjs.__name(async (directory, filename) => {
  while (directory !== path.dirname(directory)) {
    const path$1 = path.join(directory, filename);
    try {
      await promises.access(path$1);
      return path$1;
    } catch (_) {
    }
    directory = path.dirname(directory);
  }
  return null;
}, "findFileInParentDirectory");
var findWorkspaceRoot = /* @__PURE__ */ KHVGLVR5_cjs.__name(async (directory) => {
  for (const rootFile of rootFiles) {
    const path$1 = await findFileInParentDirectory(directory, rootFile);
    if (path$1) {
      return path.dirname(path$1);
    }
  }
  throw new Error(`Workspace root not found from directory: ${directory}`);
}, "findWorkspaceRoot");

exports.findFileInParentDirectory = findFileInParentDirectory;
exports.findWorkspaceRoot = findWorkspaceRoot;
exports.getCombinationId = getCombinationId;
//# sourceMappingURL=REVK4LZT.cjs.map
//# sourceMappingURL=REVK4LZT.cjs.map