uptime-kuma/extra/check-lang-json.js

28 lines
688 B
JavaScript
Raw Normal View History

2024-10-23 00:56:35 +00:00
// For #5231
const fs = require("fs");
2024-10-23 00:57:43 +00:00
let path = "./src/lang";
2024-10-23 00:56:35 +00:00
// 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);
}
}
2024-10-23 00:57:43 +00:00
console.log("All lang json files are formatted correctly.");