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

Function codeGraphDirName

src/directory.ts:35–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33 * project root itself; we warn once to stderr so the misconfiguration is seen.
34 */
35export function codeGraphDirName(): string {
36 const raw = process.env.CODEGRAPH_DIR?.trim();
37 if (!raw) return DEFAULT_CODEGRAPH_DIR;
38 const invalid =
39 raw === '.' ||
40 raw.includes('..') ||
41 raw.includes('/') ||
42 raw.includes('\\') ||
43 path.isAbsolute(raw);
44 if (invalid) {
45 if (!warnedBadDirName) {
46 warnedBadDirName = true;
47 // stderr only — stdout is the MCP protocol channel.
48 console.warn(
49 `[codegraph] Ignoring invalid CODEGRAPH_DIR="${raw}" — it must be a plain ` +
50 `directory name (no path separators, no "..", not absolute). Using "${DEFAULT_CODEGRAPH_DIR}".`
51 );
52 }
53 return DEFAULT_CODEGRAPH_DIR;
54 }
55 return raw;
56}
57
58/**
59 * CodeGraph directory name — a load-time snapshot of {@link codeGraphDirName}.

Callers 5

runUninstallerFunction · 0.90
foundation.test.tsFile · 0.90
directory.tsFile · 0.85
isCodeGraphDataDirFunction · 0.85
getCodeGraphDirFunction · 0.85

Calls 1

warnMethod · 0.80

Tested by

no test coverage detected