import { findToolVersionsForCombination } from './KWRJPB5T.js';
import { init_esm_shims, __name } from './6AHA7PAZ.js';
import { access } from 'fs/promises';
import { dirname, join } from 'path';

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

export { findFileInParentDirectory, findWorkspaceRoot, getCombinationId };
//# sourceMappingURL=WSGRZJVU.js.map
//# sourceMappingURL=WSGRZJVU.js.map