(token)
| 36 | const WASM_SPECIAL = { csharp: 'c_sharp', 'c#': 'c_sharp' }; |
| 37 | |
| 38 | function resolveWasm(token) { |
| 39 | if (token.endsWith('.wasm')) { |
| 40 | if (!existsSync(token)) fail(`wasm not found: ${token}`); |
| 41 | return token; |
| 42 | } |
| 43 | const base = WASM_SPECIAL[token.toLowerCase()] ?? token.toLowerCase(); |
| 44 | try { |
| 45 | return require.resolve(`tree-sitter-wasms/out/tree-sitter-${base}.wasm`); |
| 46 | } catch { |
| 47 | /* not in tree-sitter-wasms — try a vendored copy */ |
| 48 | } |
| 49 | const vendored = `src/extraction/wasm/tree-sitter-${base}.wasm`; |
| 50 | if (existsSync(vendored)) return vendored; |
| 51 | fail( |
| 52 | `no grammar for "${token}" — not in tree-sitter-wasms and not vendored at ` + |
| 53 | `${vendored}. Pass an explicit .wasm path, or vendor one (see SKILL.md "Find a grammar").` |
| 54 | ); |
| 55 | } |
| 56 | |
| 57 | const wasmPath = resolveWasm(langOrWasm); |
| 58 | const source = readFileSync(sampleFile, 'utf8'); |
no test coverage detected