'use strict';

var _5GPMTH2I_cjs = require('./5GPMTH2I.cjs');
var _24WEKBY3_cjs = require('./24WEKBY3.cjs');
var promises = require('fs/promises');
var path = require('path');

// src/utils.ts
_24WEKBY3_cjs.init_cjs_shims();
var rootFiles = [
  "pnpm-workspace.yaml",
  ".git"
];
var getCombinationId = /* @__PURE__ */ _24WEKBY3_cjs.__name((context, combination) => Object.entries(_5GPMTH2I_cjs.findToolVersionsForCombination(context, combination)).toSorted().flat().join("-"), "getCombinationId");
var findFileInParentDirectory = /* @__PURE__ */ _24WEKBY3_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__ */ _24WEKBY3_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=2Z4Y2ZR3.cjs.map
//# sourceMappingURL=2Z4Y2ZR3.cjs.map