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

Function validateSounds

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

Source from the content-addressed store, hash-verified

437}
438
439async function validateSounds(): Promise<void> {
440 const problems = new Problems<string, "_additional">("Sounds", {
441 _additional:
442 "Sound files present but missing in frontend/src/ts/constants/sounds",
443 });
444
445 const soundFiles = new Set(
446 fs
447 .readdirSync("./static/sounds")
448 .filter((it) => it.startsWith("click"))
449 .flatMap((folder) =>
450 fs
451 .readdirSync(`./static/sounds/${folder}`)
452 .map((it) => `${folder}/${it}`),
453 ),
454 );
455
456 //missing sound files
457
458 Object.entries(clickSoundConfig).forEach(([key, value]) => {
459 value
460 .map((file) => file.substring("../sounds/".length))
461 .filter((it) => !soundFiles.has(it))
462 .forEach((file) =>
463 problems.add(
464 `click${key}`,
465 `missing file frontend/static/sounds/${file}`,
466 ),
467 );
468 });
469
470 //additional files
471 const expectedSoundFiles = new Set(
472 Object.values(clickSoundConfig).flatMap((it) =>
473 it.map((file) => file.substring("../sounds/".length)),
474 ),
475 );
476 [...soundFiles]
477 .filter((name) => !expectedSoundFiles.has(name))
478 .forEach((file) => problems.add("_additional", file));
479
480 console.log(problems.toString());
481
482 if (problems.hasError()) {
483 throw new Error("sounds with errors");
484 }
485}
486
487type Validator = () => Promise<void>;
488

Callers

nothing calls this directly

Calls 3

addMethod · 0.95
toStringMethod · 0.95
hasErrorMethod · 0.95

Tested by

no test coverage detected