summaryrefslogtreecommitdiffstats
path: root/extra/check-lang-json.js
blob: dfda34892a91c65eb00eb4d7059d6fe7f7271be9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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.");