import {
  __name,
  init_esm_shims
} from "./chunk-BFNZYC5O.js";

// src/utilities/find-up.ts
init_esm_shims();
import { existsSync } from "node:fs";
import { join } from "node:path";
var MAX_PATH_SEARCH_DEPTH = 30;
var depth = 0;
function findFolderUp(startPath, endFileNames) {
  const _startPath = startPath ?? process.cwd();
  if (endFileNames.some((endFileName) => existsSync(join(_startPath, endFileName)))) {
    return _startPath;
  }
  if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
    const parent = join(_startPath, "..");
    return findFolderUp(parent, endFileNames);
  }
  return void 0;
}
__name(findFolderUp, "findFolderUp");

export {
  findFolderUp
};
