hedera-web/utils/parse-yaml.js

28 lines
812 B
JavaScript
Executable File

#!/usr/bin/node
var glob = require('glob');
var fs = require('fs-extra');
var yaml = require('js-yaml');
(async () => {
let projectDir = await fs.realpath(`${__dirname}/..`);
glob(`${projectDir}/**/locale/*.json`, async (err, localeFiles) => {
if (err) throw err;
for (let localeFile of localeFiles) {
if (/node_modules/.test (localeFile))
continue;
let dstFile = localeFile.replace(/\.json$/, '.yml');
let ymlString = yaml.safeDump(require(localeFile));
await fs.writeFile(dstFile, ymlString, 'utf8');
await fs.unlink(localeFile);
console.log('->', localeFile);
console.log(' ', dstFile);
}
console.log('Total %d files dumped.', localeFiles.length);
});
})();