From 61a61a555577ab4b6a62255884c1aa400b7ffe57 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Wed, 23 Oct 2024 08:56:35 +0800 Subject: [PATCH] Test --- .github/workflows/json-yaml-validate.yml | 10 ++++++++++ extra/check-lang-json.js | 25 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 extra/check-lang-json.js diff --git a/.github/workflows/json-yaml-validate.yml b/.github/workflows/json-yaml-validate.yml index b6437ec4..7942884e 100644 --- a/.github/workflows/json-yaml-validate.yml +++ b/.github/workflows/json-yaml-validate.yml @@ -25,3 +25,13 @@ jobs: with: comment: "true" # enable comment mode exclude_file: ".github/config/exclude.txt" # gitignore style file for exclusions + + check-lang-json: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + - run: node ./extra/check-lang-json.js diff --git a/extra/check-lang-json.js b/extra/check-lang-json.js new file mode 100644 index 00000000..6555f902 --- /dev/null +++ b/extra/check-lang-json.js @@ -0,0 +1,25 @@ +// 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); + } +}