{"version":3,"sources":["../../../src/loadDictionaries/loadLocalDictionaries.ts"],"sourcesContent":["import { mkdir } from 'fs/promises';\nimport { resolve, relative } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { loadContentDeclarations } from './loadContentDeclaration';\n\nexport const loadLocalDictionaries = async (\n  contentDeclarationsPaths: string[] | string\n): Promise<Dictionary[]> => {\n  const { content } = getConfiguration();\n  const { dictionariesDir, baseDir } = content;\n\n  if (typeof contentDeclarationsPaths === 'string') {\n    contentDeclarationsPaths = [contentDeclarationsPaths];\n  }\n\n  // Create the dictionaries folder if it doesn't exist\n  await mkdir(resolve(dictionariesDir), { recursive: true });\n\n  const result: Dictionary[] = [];\n\n  for await (const contentDeclarationPath of contentDeclarationsPaths) {\n    const dictionary = await loadContentDeclarations([contentDeclarationPath]);\n\n    const relativeFilePath = relative(baseDir, contentDeclarationPath);\n\n    const dictionaryWithPath: Dictionary = {\n      ...dictionary[0],\n      filePath: relativeFilePath,\n    };\n\n    result.push(dictionaryWithPath);\n  }\n\n  return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAsB;AACtB,kBAAkC;AAClC,oBAAiC;AAEjC,oCAAwC;AAEjC,MAAM,wBAAwB,OACnC,6BAC0B;AAC1B,QAAM,EAAE,QAAQ,QAAI,gCAAiB;AACrC,QAAM,EAAE,iBAAiB,QAAQ,IAAI;AAErC,MAAI,OAAO,6BAA6B,UAAU;AAChD,+BAA2B,CAAC,wBAAwB;AAAA,EACtD;AAGA,YAAM,2BAAM,qBAAQ,eAAe,GAAG,EAAE,WAAW,KAAK,CAAC;AAEzD,QAAM,SAAuB,CAAC;AAE9B,mBAAiB,0BAA0B,0BAA0B;AACnE,UAAM,aAAa,UAAM,uDAAwB,CAAC,sBAAsB,CAAC;AAEzE,UAAM,uBAAmB,sBAAS,SAAS,sBAAsB;AAEjE,UAAM,qBAAiC;AAAA,MACrC,GAAG,WAAW,CAAC;AAAA,MACf,UAAU;AAAA,IACZ;AAEA,WAAO,KAAK,kBAAkB;AAAA,EAChC;AAEA,SAAO;AACT;","names":[]}