forked from verdnatura/hedera-web
28 lines
812 B
JavaScript
28 lines
812 B
JavaScript
|
#!/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);
|
||
|
});
|
||
|
})();
|