Created
November 28, 2017 10:23
-
-
Save pdemanget/fa6d2434b73f01a3a5aa62afe9925f89 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to launch it from npm install:
"watch:yaml": "watch "npm run build:yaml" src/assets/i18n",
"start": "npm run watch:yaml | npm run yourlaunch",