MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / rewriteSourceLangFile

Method rewriteSourceLangFile

scripts/useless-key-scanner.mjs:36–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34 }
35
36 async rewriteSourceLangFile() {
37 for (const [key, value] of this.keysMap) {
38 if (!value) {
39 delete this.sourceLangMap[key];
40 }
41 }
42 console.log("Rewrite file:", path.join(LANGUAGE_DIR, LANGUAGE_SOURCE_FILE_NAME));
43 fs.writeFileSync(
44 path.join(LANGUAGE_DIR, LANGUAGE_SOURCE_FILE_NAME),
45 JSON.stringify(this.sourceLangMap, null, 2)
46 );
47 for (const filename of await fs.promises.readdir(this.languageDir)) {
48 if (filename.endsWith(".json")) {
49 const otherLangMap = JSON.parse(
50 fs.readFileSync(path.join(this.languageDir, filename), "utf-8")
51 );
52 for (const key in otherLangMap) {
53 if (!this.sourceLangMap[key]) {
54 delete otherLangMap[key];
55 }
56 }
57 console.log("Rewrite other lang file:", path.join(this.languageDir, filename));
58 fs.writeFileSync(
59 path.join(this.languageDir, filename),
60 JSON.stringify(otherLangMap, null, 2)
61 );
62 }
63 }
64 }
65}
66
67/**

Callers 1

mainThreadFunction · 0.95

Calls 1

logMethod · 0.80

Tested by

no test coverage detected