0
1
Fork 0
hedera-web-mindshore/utils/parse-yaml.js

28 lines
812 B
JavaScript
Raw Permalink Normal View History

2018-02-05 12:58:17 +00:00
#!/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);
});
})();