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 (23 loc) 1.14 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _chunkUSNT2KNTcjs = require('./chunk-USNT2KNT.cjs'); // src/utilities/find-up.ts var _fs = require('fs'); var _path = require('path'); var MAX_PATH_SEARCH_DEPTH = 30; var depth = 0; function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) { const _startPath = _nullishCoalesce(startPath, () => ( process.cwd())); if (endDirectoryNames.some((endDirName) => _fs.existsSync.call(void 0, _path.join.call(void 0, _startPath, endDirName)))) { return _startPath; } if (endFileNames.some((endFileName) => _fs.existsSync.call(void 0, _path.join.call(void 0, _startPath, endFileName)))) { return _startPath; } if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) { const parent = _path.join.call(void 0, _startPath, ".."); return findFolderUp(parent, endFileNames, endDirectoryNames); } return void 0; } _chunkUSNT2KNTcjs.__name.call(void 0, findFolderUp, "findFolderUp"); exports.findFolderUp = findFolderUp;