From 890980d534fc8d8e46f9e87f2aed1202bc08d499 Mon Sep 17 00:00:00 2001 From: Robin van der Linde Date: Wed, 1 Feb 2023 11:57:26 +0100 Subject: [PATCH] Fix extractlayer and contributors script --- scripts/extractLayer.ts | 2 +- scripts/generateContributors.ts | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/scripts/extractLayer.ts b/scripts/extractLayer.ts index 5fd0c4306..66f52ddb1 100644 --- a/scripts/extractLayer.ts +++ b/scripts/extractLayer.ts @@ -15,7 +15,7 @@ function main(args: string[]) { const layerId = args[1] const themePath = "./assets/themes/" + themeId + "/" + themeId + ".json" - const contents = JSON.parse(readFileSync(themePath, "UTF-8")) + const contents = JSON.parse(readFileSync(themePath, { encoding: "utf8" })) const layers = contents.layers.filter((l) => { if (typeof l === "string") { return false diff --git a/scripts/generateContributors.ts b/scripts/generateContributors.ts index 80643a3a6..6f526383a 100644 --- a/scripts/generateContributors.ts +++ b/scripts/generateContributors.ts @@ -1,10 +1,23 @@ import { exec } from "child_process" import { writeFile, writeFileSync } from "fs" -function asList(hist: Map): { - contributors: { contributor: string; commits: number }[] -} { - const ls = [] +interface Contributor { + /** + * The name of the contributor + */ + contributor: string + /** + * The number of commits + */ + commits: number +} + +interface ContributorList { + contributors: Contributor[] +} + +function asList(hist: Map): ContributorList { + const ls: Contributor[] = [] hist.forEach((commits, contributor) => { ls.push({ commits, contributor }) })