Skip to content

Commit

Permalink
Sort only en locale file in the sort-locale script; Update docker a…
Browse files Browse the repository at this point in the history
…nd CI to use `npm run install-all` (#8813)
  • Loading branch information
rithviknishad authored Oct 17, 2024
1 parent ef3403a commit 8d4640b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"cpus": 4
},
"waitFor": "onCreateCommand",
"postCreateCommand": "npm install",
"postCreateCommand": "npm run install-all",
"postAttachCommand": {
"server": "npm run dev"
},
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cypress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
node-version: "20"

- name: Install dependencies 📦
run: npm install
run: npm run install-all

- name: Build ⚙️
run: npm run build
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ RUN npm install

COPY . .

RUN npm run setup

RUN npm run build


Expand Down
29 changes: 9 additions & 20 deletions scripts/sort-locales.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require("fs");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require("path");

const directory = "src/Locale";

fs.readdir(directory, (err, files) => {
if (err) throw err;
const file = "src/Locale/en.json";

files.forEach((file) => {
if (file.endsWith(".json")) {
const filePath = path.join(directory, file);
const data = JSON.parse(fs.readFileSync(filePath, "utf8"));
const data = JSON.parse(fs.readFileSync(file, "utf8"));

const sortedData = Object.keys(data)
.sort()
.reduce((acc, key) => {
acc[key] = data[key];
return acc;
}, {});
const sortedData = Object.keys(data)
.sort()
.reduce((acc, key) => {
acc[key] = data[key];
return acc;
}, {});

fs.writeFileSync(filePath, JSON.stringify(sortedData, null, 2) + "\n");
}
});
});
fs.writeFileSync(file, JSON.stringify(sortedData, null, 2) + "\n");

0 comments on commit 8d4640b

Please sign in to comment.