Refactor script into separate modules

This commit is contained in:
mtkennerly 2020-07-14 15:54:45 -04:00
parent 88ba4dd5e5
commit dd63fdb183
8 changed files with 371 additions and 354 deletions

15
src/missing.ts Normal file
View file

@ -0,0 +1,15 @@
import * as fs from "fs";
import { REPO } from ".";
import { Manifest } from "./manifest";
import { WikiGameCache } from "./wiki";
export function saveMissingGames(cache: WikiGameCache, manifest: Manifest): void {
fs.writeFileSync(
`${REPO}/data/missing.md`,
Object.entries(cache)
.sort((x, y) => x[0].localeCompare(y[0]))
.filter(([k, _]) => (manifest[k]?.files ?? []).length === 0 && (manifest[k]?.registry ?? []).length === 0)
.map(([k, v]) => `* [${k}](https://www.pcgamingwiki.com/wiki/?curid=${v.pageId})`)
.join("\n") + "\n",
);
}