@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.
30 lines (29 loc) • 934 B
JavaScript
import { findUp, findUpSync } from "find-up";
import Logger from "@smooai/logger/Logger";
//#region src/file/findFile.ts
const logger = new Logger({ name: "findFile" });
const 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;
}
};
const 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;
}
};
//#endregion
export { findFile, findFileSync };
//# sourceMappingURL=findFile.mjs.map