-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathfix.ts
42 lines (32 loc) · 1019 Bytes
/
fix.ts
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { walkSync } from 'https://deno.land/[email protected]/fs/mod.ts';
for (const entry of walkSync('./data')) {
console.log(entry.path);
if (entry.isFile && (entry.path.includes("games") || entry.path.includes("game_portals") && entry.name.includes(".json")) ) {
const obj = JSON.parse(Deno.readTextFileSync(entry.path));
if ("translation" in obj) {
obj["name"] = {translate: obj["translation"]}
delete obj["translation"]
}
if ("games" in obj && entry.path.includes("game_portals")) {
const newGames = [];
for (const game of obj["games"]) {
if (game == null) {
continue;
}
newGames.push(game["game"] || game)
}
obj["games"] = newGames
}
if ("custom" in obj) {
const custom = obj["custom"];
if ("gamegui:icon" in custom) {
obj["icon"] = custom["gamegui:icon"];
delete custom["gamegui:icon"];
}
if (Object.values(custom).length == 0) {
delete obj["custom"];
}
}
Deno.writeTextFileSync(entry.path, JSON.stringify(obj, null, 2))
}
}