{"version":3,"file":"getBuiltFetchDictionariesPath.mjs","names":[],"sources":["../../../src/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { basename } from 'node:path';\nimport { normalizePath } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const getBuiltFetchDictionariesPath = async (\n  configuration: IntlayerConfig,\n  format: 'cjs' | 'esm' = 'esm',\n  excludeKeys: string[] = []\n) => {\n  const { fetchDictionariesDir, mainDir } = configuration.system;\n\n  // Create main directory if it doesn't exist\n  if (!existsSync(mainDir)) {\n    await mkdir(mainDir, { recursive: true });\n  }\n\n  const extension = format === 'cjs' ? 'cjs' : 'mjs';\n\n  const dictionariesPath: string[] = await fg(\n    `${normalizePath(fetchDictionariesDir)}/*.${extension}`\n  );\n\n  return dictionariesPath.filter((path) => {\n    const key = basename(path, `.${extension}`);\n    return !excludeKeys.includes(key);\n  });\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,gCAAgC,OAC3C,eACA,SAAwB,OACxB,cAAwB,EAAE,KACvB;CACH,MAAM,EAAE,sBAAsB,YAAY,cAAc;AAGxD,KAAI,CAAC,WAAW,QAAQ,CACtB,OAAM,MAAM,SAAS,EAAE,WAAW,MAAM,CAAC;CAG3C,MAAM,YAAY,WAAW,QAAQ,QAAQ;AAM7C,SAAO,MAJkC,GACvC,GAAG,cAAc,qBAAqB,CAAC,KAAK,YAC7C,EAEuB,QAAQ,SAAS;EACvC,MAAM,MAAM,SAAS,MAAM,IAAI,YAAY;AAC3C,SAAO,CAAC,YAAY,SAAS,IAAI;GACjC"}