@intlayer/chokidar
Version:
Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.
27 lines • 1.03 kB
JavaScript
import { mkdir } from "fs/promises";
import { resolve, relative } from "path";
import { getConfiguration } from "@intlayer/config";
import { loadContentDeclarations } from "./loadContentDeclaration.mjs";
const loadLocalDictionaries = async (contentDeclarationsPaths) => {
const { content } = getConfiguration();
const { dictionariesDir, baseDir } = content;
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]);
const relativeFilePath = relative(baseDir, contentDeclarationPath);
const dictionaryWithPath = {
...dictionary[0],
filePath: relativeFilePath
};
result.push(dictionaryWithPath);
}
return result;
};
export {
loadLocalDictionaries
};
//# sourceMappingURL=loadLocalDictionaries.mjs.map