Verify language json files format (#5233)

This commit is contained in:
Louis Lam
2024-10-23 12:47:04 +08:00
committed by GitHub
parent 7a82ae039c
commit 79a26180af
2 changed files with 37 additions and 0 deletions

27
extra/check-lang-json.js Normal file
View File

@@ -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.");