UNPKG

@intlayer/chokidar

Version:

Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.

26 lines (24 loc) 1.05 kB
import { loadContentDeclarations } from "./loadContentDeclaration.mjs"; import { mkdir } from "node:fs/promises"; import { relative, resolve } from "node:path"; //#region src/loadDictionaries/loadLocalDictionaries.ts const loadLocalDictionaries = async (contentDeclarationsPaths, configuration) => { const { system } = configuration; const { dictionariesDir, baseDir } = system; if (typeof contentDeclarationsPaths === "string") contentDeclarationsPaths = [contentDeclarationsPaths]; await mkdir(resolve(dictionariesDir), { recursive: true }); const result = []; for await (const contentDeclarationPath of contentDeclarationsPaths) { const dictionary = await loadContentDeclarations([contentDeclarationPath], configuration); const relativeFilePath = relative(baseDir, contentDeclarationPath); const dictionaryWithPath = { ...dictionary[0], filePath: relativeFilePath }; result.push(dictionaryWithPath); } return result; }; //#endregion export { loadLocalDictionaries }; //# sourceMappingURL=loadLocalDictionaries.mjs.map