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

Function codeGraphDirName

src/directory.ts:47–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 5

runInitFunction · 0.90
foundation.test.tsFile · 0.90
directory.tsFile · 0.85
isCodeGraphDataDirFunction · 0.85
codeGraphDirNameForFunction · 0.85

Calls 1

warnMethod · 0.80

Tested by

no test coverage detected