MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / initializeTreeSitter

Function initializeTreeSitter

src/services/tree-sitter/__tests__/helpers.ts:32–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30
31// Function to initialize tree-sitter
32export async function initializeTreeSitter() {
33 if (!initializedTreeSitter) {
34 // Initialize directly using the default export or the module itself
35 await Parser.init()
36
37 // Override the Parser.Language.load to use dist directory
38 const originalLoad = Language.load
39
40 Language.load = async (wasmPath: string) => {
41 const filename = path.basename(wasmPath)
42 const correctPath = path.join(process.cwd(), "dist", filename)
43 // console.log(`Redirecting WASM load from ${wasmPath} to ${correctPath}`)
44 return originalLoad(correctPath)
45 }
46
47 initializedTreeSitter = { Parser, Language }
48 }
49
50 return initializedTreeSitter
51}
52
53// Test helper for parsing source code definitions
54export async function testParseSourceCodeDefinitions(

Calls 1

cwdMethod · 0.45

Tested by

no test coverage detected