MCPcopy Index your code
hub / github.com/monkeytypegame/monkeytype / validateFonts

Function validateFonts

frontend/scripts/check-assets.ts:352–395  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

350}
351
352async function validateFonts(): Promise<void> {
353 const problems = new Problems<KnownFontName, "_additional">("Fonts", {
354 _additional:
355 "Font files present but missing in frontend/src/ts/constants/fonts.ts",
356 });
357
358 //no missing files
359 const ignoredFonts = new Set([
360 "GallaudetRegular.woff2", //used for asl
361 "Vazirharf-NL-Regular.woff2", //default font
362 ]);
363
364 const fontFiles = fs
365 .readdirSync("./static/webfonts")
366 .filter((it) => !ignoredFonts.has(it));
367
368 //missing font files
369 Object.entries(Fonts)
370 .filter(([_name, config]) => !config.systemFont)
371 .filter(([_name, config]) => !fontFiles.includes(config.fileName as string))
372 .forEach(([name, config]) =>
373 problems.add(
374 name as KnownFontName,
375 `missing file frontend/static/webfonts/${config.fileName}`,
376 ),
377 );
378
379 //additional font files
380 const expectedFontFiles = new Set(
381 Object.entries(Fonts)
382 .filter(([_name, config]) => !config.systemFont)
383 .map(([_name, config]) => config.fileName as string),
384 );
385
386 fontFiles
387 .filter((name) => !expectedFontFiles.has(name))
388 .forEach((file) => problems.add("_additional", file));
389
390 console.log(problems.toString());
391
392 if (problems.hasError()) {
393 throw new Error("layouts with errors");
394 }
395}
396
397async function validateThemes(): Promise<void> {
398 const problems = new Problems<ThemeName, "_additional">("Themes", {

Callers

nothing calls this directly

Calls 3

addMethod · 0.95
toStringMethod · 0.95
hasErrorMethod · 0.95

Tested by

no test coverage detected