@intlayer/chokidar
Version:
Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.
1 lines • 1.86 kB
Source Map (JSON)
{"version":3,"file":"loadLocalDictionaries.cjs","names":["loadContentDeclarations"],"sources":["../../../src/loadDictionaries/loadLocalDictionaries.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { loadContentDeclarations } from './loadContentDeclaration';\n\nexport const loadLocalDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<Dictionary[]> => {\n const { system } = configuration;\n const { dictionariesDir, baseDir } = system;\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(\n [contentDeclarationPath],\n configuration\n );\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":";;;;;;;AAMA,MAAa,wBAAwB,OACnC,0BACA,kBAC0B;CAC1B,MAAM,EAAE,WAAW;CACnB,MAAM,EAAE,iBAAiB,YAAY;CAErC,IAAI,OAAO,6BAA6B,UACtC,2BAA2B,CAAC,wBAAwB;CAItD,yDAAoB,eAAe,GAAG,EAAE,WAAW,KAAK,CAAC;CAEzD,MAAM,SAAuB,CAAC;CAE9B,WAAW,MAAM,0BAA0B,0BAA0B;EACnE,MAAM,aAAa,MAAMA,wEACvB,CAAC,sBAAsB,GACvB,aACF;EAEA,MAAM,2CAA4B,SAAS,sBAAsB;EAEjE,MAAM,qBAAiC;GACrC,GAAG,WAAW;GACd,UAAU;EACZ;EAEA,OAAO,KAAK,kBAAkB;CAChC;CAEA,OAAO;AACT"}