UNPKG

@smooai/utils

Version:

A collection of shared utilities and tools used across SmooAI projects. This package provides common functionality to standardize and simplify development across all SmooAI repositories.

37 lines (36 loc) 1 kB
import "../chunk-LZOMFHX3.mjs"; // src/file/findFile.ts import Logger from "@smooai/logger/Logger"; import { findUp, findUpSync } from "find-up"; var logger = new Logger({ name: "findFile" }); var findFile = async (filename, options) => { const logError = options?.logError ?? true; try { const foundPath = await findUp(filename); if (!foundPath) { throw new Error(`Unable to find ${filename}`); } return foundPath; } catch (error) { if (logError) logger.error(error, `Error finding file '${filename}`); throw error; } }; var findFileSync = (filename, options) => { const logError = options?.logError ?? true; try { const foundPath = findUpSync(filename); if (!foundPath) { throw new Error(`Unable to find ${filename}`); } return foundPath; } catch (error) { if (logError) logger.error(error, `Error finding file '${filename}`); throw error; } }; export { findFile, findFileSync }; //# sourceMappingURL=findFile.mjs.map