MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / loadCodeGraph

Function loadCodeGraph

src/bin/codegraph.ts:87–99  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85
86// Lazy-load heavy modules (CodeGraph, runInstaller) to keep CLI startup fast.
87async function loadCodeGraph(): Promise<typeof import('../index')> {
88 try {
89 return await import('../index');
90 } catch (err) {
91 const msg = err instanceof Error ? err.message : String(err);
92 const [red, reset] = COLORS_ENABLED ? ['\x1b[31m', '\x1b[0m'] : ['', ''];
93 console.error(`${red}${getGlyphs().err}${reset} Failed to load CodeGraph modules.`);
94 console.error(`\n Node: ${process.version} Platform: ${process.platform} ${process.arch}`);
95 console.error(`\n Error: ${msg}`);
96 console.error('\n Try reinstalling with: npm install -g @colbymchenry/codegraph\n');
97 process.exit(1);
98 }
99}
100
101// Dynamic import helper — tsc compiles import() to require() in CJS mode,
102// which fails for ESM-only packages. This bypasses the transformation.

Callers 4

openIndexToReadFunction · 0.70
readLastIndexRunFunction · 0.70
runInitFunction · 0.70
mainFunction · 0.70

Calls 3

getGlyphsFunction · 0.90
exitMethod · 0.80
errorMethod · 0.65

Tested by

no test coverage detected