UNPKG

@rxap/plugin-localazy

Version:

This package provides executors and generators for integrating Localazy, a translation management platform, into Nx workspaces. It allows for downloading and uploading translations, managing configuration, and initializing Localazy within a project. The p

39 lines 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LoadKeysFromFile = LoadKeysFromFile; const fs_1 = require("fs"); function LoadKeysFromFile(projectName) { if (!projectName) { console.log('Could not load keys from file. Project name is not set'); return {}; } if (process.env.LOCALAZY_KEY_MAP) { const filePath = process.env.LOCALAZY_KEY_MAP; console.log('Load keys from file', filePath); if (!(0, fs_1.existsSync)(filePath)) { console.log('File does not exist', filePath); return {}; } const content = (0, fs_1.readFileSync)(filePath, 'utf-8'); try { const map = JSON.parse(content); if (typeof map === 'object' && map[projectName]) { if (typeof map[projectName] === 'string') { return { read: null, write: map[projectName] }; } if (typeof map[projectName] === 'object') { return map[projectName]; } } console.log(`Could not find project '${projectName}' in file '${filePath}' with map`, JSON.stringify(map, null, 2)); return {}; } catch (e) { console.log(`Could not parse file '${filePath}' with content`, content); return {}; } } console.log('Could not load keys from file. LOCALAZY_KEY_MAP is not set'); return {}; } //# sourceMappingURL=load-keys-from-file.js.map