UNPKG

@techmely/utils

Version:

Collection of helpful JavaScript / TypeScript utils

20 lines (17 loc) 584 B
import { getDataPath } from './chunk-QUUMHGGA.mjs'; import './chunk-YCYRHAJ6.mjs'; import './chunk-NYLAFCGV.mjs'; import path from 'path'; async function findNearestFile(fileName, directoryPath = path.resolve()) { try { const data = await getDataPath(directoryPath, fileName); return data; } catch (error) { const parentDirectoryPath = path.dirname(directoryPath); if (parentDirectoryPath === directoryPath) { throw new Error(`No ${fileName} files found`); } return findNearestFile(parentDirectoryPath, fileName); } } export { findNearestFile };