diff options
Diffstat (limited to 'extra/check-lang-json.js')
-rw-r--r-- | extra/check-lang-json.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/extra/check-lang-json.js b/extra/check-lang-json.js new file mode 100644 index 0000000..dfda348 --- /dev/null +++ b/extra/check-lang-json.js @@ -0,0 +1,27 @@ +// For #5231 + +const fs = require("fs"); + +let path = "./src/lang"; + +// list directories in the lang directory +let jsonFileList = fs.readdirSync(path); + +for (let jsonFile of jsonFileList) { + if (!jsonFile.endsWith(".json")) { + continue; + } + + let jsonPath = path + "/" + jsonFile; + let originalContent = fs.readFileSync(jsonPath, "utf8"); + let langData = JSON.parse(originalContent); + + let formattedContent = JSON.stringify(langData, null, 4) + "\n"; + + if (originalContent !== formattedContent) { + console.error(`File ${jsonFile} is not formatted correctly.`); + process.exit(1); + } +} + +console.log("All lang json files are formatted correctly."); |