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

Function codeGraphDirName

src/directory.ts:46–67  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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