UNPKG

@intlayer/chokidar

Version:

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

25 lines (23 loc) 1.01 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const require_runtime = require('../_virtual/_rolldown/runtime.cjs'); let node_path = require("node:path"); let node_fs = require("node:fs"); //#region src/utils/readDictionariesFromDisk.ts /** * Reads all JSON dictionary files from a directory, keyed by filename. * Uses readFileSync instead of require() to avoid require.cache memory leak. */ const readDictionariesFromDisk = (directory) => { const dictionaries = {}; if ((0, node_fs.existsSync)(directory)) { const files = (0, node_fs.readdirSync)(directory).filter((file) => file.endsWith(".json")); for (const file of files) { const key = (0, node_path.basename)(file, (0, node_path.extname)(file)); dictionaries[key] = JSON.parse((0, node_fs.readFileSync)((0, node_path.join)(directory, file), "utf-8")); } } return dictionaries; }; //#endregion exports.readDictionariesFromDisk = readDictionariesFromDisk; //# sourceMappingURL=readDictionariesFromDisk.cjs.map