Skip to content

Instantly share code, notes, and snippets.

@pdemanget
Created November 28, 2017 10:23
Show Gist options
  • Save pdemanget/fa6d2434b73f01a3a5aa62afe9925f89 to your computer and use it in GitHub Desktop.
Save pdemanget/fa6d2434b73f01a3a5aa62afe9925f89 to your computer and use it in GitHub Desktop.
#
# use npm install js-yaml
const fs = require('fs')
const jsyaml = require('js-yaml')
const mkdirSync = function (dirPath) {
try {
fs.mkdirSync(dirPath)
} catch (err) {
if (err.code !== 'EEXIST') throw err
}
}
function convertData( srcPath, savPath) {
fs.readFile(srcPath, 'utf8', function (err, data) {
if (err) throw err;
let json = JSON.stringify(jsyaml.load(data),null,2);
//Do your processing, MD5, send a satellite to the moon, etc.
fs.writeFile (savPath, json, function(err) {
if (err) throw err;
console.log('Json complete '+new Date().toTimeString());
});
});
}
mkdirSync("www");
mkdirSync("www/assets");
mkdirSync("www/assets/i18n");
convertData("src/assets/i18n/fr.yaml","www/assets/i18n/fr.json");
@pdemanget
Copy link
Author

to launch it from npm install:
"watch:yaml": "watch "npm run build:yaml" src/assets/i18n",
"start": "npm run watch:yaml | npm run yourlaunch",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment