Created
June 12, 2015 08:37
-
-
Save tinganho/34dd5afc0543326e1f4e to your computer and use it in GitHub Desktop.
Generate Diagnostics file
This file contains hidden or 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
function() { | |
var json = require('./errors/errors.json'); | |
var errorText = 'export default {\n'; | |
var length = Object.keys(json).length; | |
var index = 0; | |
for (var error in json) { | |
errorText += ' ' + | |
error.replace(/\s+/g, '_') | |
.replace(/['"\.]/g, '') | |
.replace(/{(\d)}/g, '$1'); | |
errorText += ': {\n'; | |
errorText += ' message: \'' + error + '\',\n'; | |
errorText += ' code: ' + json[error].code + '\n'; | |
errorText += ' }\n'; | |
if (index < length - 1) { | |
errorText += ','; | |
} | |
index++; | |
} | |
errorText += '}'; | |
fs.writeFileSync(path.join(__dirname, 'errors/errors.ts'), errorText); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment