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

Function loadCodeGraph

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

Source from the content-addressed store, hash-verified

60
61// Lazy-load heavy modules (CodeGraph, runInstaller) to keep CLI startup fast.
62async function loadCodeGraph(): Promise<typeof import('../index')> {
63 try {
64 return await import('../index');
65 } catch (err) {
66 const msg = err instanceof Error ? err.message : String(err);
67 const [red, reset] = COLORS_ENABLED ? ['\x1b[31m', '\x1b[0m'] : ['', ''];
68 console.error(`${red}${getGlyphs().err}${reset} Failed to load CodeGraph modules.`);
69 console.error(`\n Node: ${process.version} Platform: ${process.platform} ${process.arch}`);
70 console.error(`\n Error: ${msg}`);
71 console.error('\n Try reinstalling with: npm install -g @colbymchenry/codegraph\n');
72 process.exit(1);
73 }
74}
75
76// Dynamic import helper — tsc compiles import() to require() in CJS mode,
77// which fails for ESM-only packages. This bypasses the transformation.

Callers 1

mainFunction · 0.70

Calls 2

getGlyphsFunction · 0.90
errorMethod · 0.80

Tested by

no test coverage detected