UNPKG

@intlayer/chokidar

Version:

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

28 lines (26 loc) 1.34 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const require_runtime = require('../_virtual/_rolldown/runtime.cjs'); const require_loadDictionaries_loadContentDeclaration = require('./loadContentDeclaration.cjs'); let node_fs_promises = require("node:fs/promises"); let node_path = require("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 (0, node_fs_promises.mkdir)((0, node_path.resolve)(dictionariesDir), { recursive: true }); const result = []; for await (const contentDeclarationPath of contentDeclarationsPaths) { const dictionary = await require_loadDictionaries_loadContentDeclaration.loadContentDeclarations([contentDeclarationPath], configuration); const relativeFilePath = (0, node_path.relative)(baseDir, contentDeclarationPath); const dictionaryWithPath = { ...dictionary[0], filePath: relativeFilePath }; result.push(dictionaryWithPath); } return result; }; //#endregion exports.loadLocalDictionaries = loadLocalDictionaries; //# sourceMappingURL=loadLocalDictionaries.cjs.map