@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.
1 lines • 1.7 kB
Source Map (JSON)
{"version":3,"file":"findFile.mjs","names":[],"sources":["../../src/file/findFile.ts"],"sourcesContent":["import { findUp, findUpSync } from 'find-up';\nimport Logger from '@smooai/logger/Logger';\n\nconst logger = new Logger({ name: 'findFile' });\n\nexport const findFile = async (filename: string, options?: { logError: boolean }) => {\n const logError = options?.logError ?? true;\n try {\n const foundPath = await findUp(filename);\n if (!foundPath) {\n throw new Error(`Unable to find ${filename}`);\n }\n return foundPath;\n } catch (error) {\n if (logError) logger.error(error, `Error finding file '${filename}`);\n throw error;\n }\n};\n\nexport const findFileSync = (filename: string, options?: { logError: boolean }) => {\n const logError = options?.logError ?? true;\n try {\n const foundPath = findUpSync(filename);\n if (!foundPath) {\n throw new Error(`Unable to find ${filename}`);\n }\n return foundPath;\n } catch (error) {\n if (logError) logger.error(error, `Error finding file '${filename}`);\n throw error;\n }\n};\n"],"mappings":";;;AAGA,MAAM,SAAS,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAa,WAAW,OAAO,UAAkB,YAAoC;CACjF,MAAM,WAAW,SAAS,YAAY;CACtC,IAAI;EACA,MAAM,YAAY,MAAM,OAAO,QAAQ;EACvC,IAAI,CAAC,WACD,MAAM,IAAI,MAAM,kBAAkB,UAAU;EAEhD,OAAO;CACX,SAAS,OAAO;EACZ,IAAI,UAAU,OAAO,MAAM,OAAO,uBAAuB,UAAU;EACnE,MAAM;CACV;AACJ;AAEA,MAAa,gBAAgB,UAAkB,YAAoC;CAC/E,MAAM,WAAW,SAAS,YAAY;CACtC,IAAI;EACA,MAAM,YAAY,WAAW,QAAQ;EACrC,IAAI,CAAC,WACD,MAAM,IAAI,MAAM,kBAAkB,UAAU;EAEhD,OAAO;CACX,SAAS,OAAO;EACZ,IAAI,UAAU,OAAO,MAAM,OAAO,uBAAuB,UAAU;EACnE,MAAM;CACV;AACJ"}