MCPcopy
hub / github.com/colbymchenry/codegraph / resolveWasm

Function resolveWasm

scripts/add-lang/check-grammar.mjs:31–38  ·  view source on GitHub ↗
(t)

Source from the content-addressed store, hash-verified

29
30const SPECIAL = { csharp: 'c_sharp', 'c#': 'c_sharp' };
31function resolveWasm(t) {
32 if (t.endsWith('.wasm')) return existsSync(t) ? t : fail(2, `wasm not found: ${t}`);
33 const base = SPECIAL[t.toLowerCase()] ?? t.toLowerCase();
34 try { return require.resolve(`tree-sitter-wasms/out/tree-sitter-${base}.wasm`); } catch { /* try vendored */ }
35 const vendored = `src/extraction/wasm/tree-sitter-${base}.wasm`;
36 if (existsSync(vendored)) return vendored;
37 return fail(2, `no grammar for "${t}" — not in tree-sitter-wasms and not vendored`);
38}
39
40const wasmPath = resolveWasm(token);
41const source = readFileSync(sample, 'utf8');

Callers 1

check-grammar.mjsFile · 0.70

Calls 2

resolveMethod · 0.80
failFunction · 0.70

Tested by

no test coverage detected