MCPcopy Create free account
hub / github.com/EmNudge/watlings / getPatchMap

Function getPatchMap

tests/_meta/patch.test.js:25–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23
24/** @returns {Promise<Map<string, { exercise: string, patch?: string }>>} */
25const getPatchMap = async () => {
26 const [exercises, patches] = await Promise.all([
27 getFilesInFolder("../../exercises"),
28 getFilesInFolder("../../patch"),
29 ]);
30
31 const map = new Map();
32 for (const { name, content } of exercises) {
33 if (!name.endsWith(".wat")) continue;
34
35 map.set(basename(name, ".wat"), { exercise: content });
36 }
37
38 for (const { name, content } of patches) {
39 if (!name.endsWith(".patch")) continue;
40
41 const baseName = basename(name, ".patch");
42 if (!map.has(baseName)) {
43 console.log(map);
44 throw new Error(`No exercise file found for patch ${name}`);
45 }
46 map.get(baseName).patch = content;
47 }
48
49 return map;
50};
51
52test("each file has an associated patch", async () => {
53 const patchMap = await getPatchMap();

Callers 1

patch.test.jsFile · 0.85

Calls 1

getFilesInFolderFunction · 0.85

Tested by

no test coverage detected