@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.79 kB
Source Map (JSON)
{"version":3,"sources":["../../src/file/findFile.ts"],"sourcesContent":["import Logger from '@smooai/logger/Logger';\nimport { findUp, findUpSync } from 'find-up';\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":";;;AAAA,OAAO,YAAY;AACnB,SAAS,QAAQ,kBAAkB;AAEnC,IAAM,SAAS,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAEvC,IAAM,WAAW,OAAO,UAAkB,YAAoC;AACjF,QAAM,WAAW,SAAS,YAAY;AACtC,MAAI;AACA,UAAM,YAAY,MAAM,OAAO,QAAQ;AACvC,QAAI,CAAC,WAAW;AACZ,YAAM,IAAI,MAAM,kBAAkB,QAAQ,EAAE;AAAA,IAChD;AACA,WAAO;AAAA,EACX,SAAS,OAAO;AACZ,QAAI,SAAU,QAAO,MAAM,OAAO,uBAAuB,QAAQ,EAAE;AACnE,UAAM;AAAA,EACV;AACJ;AAEO,IAAM,eAAe,CAAC,UAAkB,YAAoC;AAC/E,QAAM,WAAW,SAAS,YAAY;AACtC,MAAI;AACA,UAAM,YAAY,WAAW,QAAQ;AACrC,QAAI,CAAC,WAAW;AACZ,YAAM,IAAI,MAAM,kBAAkB,QAAQ,EAAE;AAAA,IAChD;AACA,WAAO;AAAA,EACX,SAAS,OAAO;AACZ,QAAI,SAAU,QAAO,MAAM,OAAO,uBAAuB,QAAQ,EAAE;AACnE,UAAM;AAAA,EACV;AACJ;","names":[]}