UNPKG

@storm-software/config-tools

Version:

⚡The Storm-Ops monorepo contains utility applications, tools, and various libraries to create modern and scalable web applications.

29 lines (26 loc) 815 B
import { __name } from "./chunk-SHUYVCID.js"; // src/utilities/find-up.ts import { existsSync } from "node:fs"; import { join } from "node:path"; var MAX_PATH_SEARCH_DEPTH = 30; var depth = 0; function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) { const _startPath = startPath ?? process.cwd(); if (endDirectoryNames.some((endDirName) => existsSync(join(_startPath, endDirName)))) { return _startPath; } 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, endDirectoryNames); } return void 0; } __name(findFolderUp, "findFolderUp"); export { findFolderUp };