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

Function ensureSubdirectory

src/directory.ts:568–580  ·  view source on GitHub ↗
(projectRoot: string, subdirName: string)

Source from the content-addressed store, hash-verified

566 * Ensure a subdirectory exists within .codegraph
567 */
568export function ensureSubdirectory(projectRoot: string, subdirName: string): string {
569 if (subdirName.includes('..') || subdirName.includes(path.sep) || subdirName.includes('/')) {
570 throw new Error(`Invalid subdirectory name: ${subdirName}`);
571 }
572
573 const subdirPath = path.join(getCodeGraphDir(projectRoot), subdirName);
574
575 if (!fs.existsSync(subdirPath)) {
576 fs.mkdirSync(subdirPath, { recursive: true });
577 }
578
579 return subdirPath;
580}
581
582/**
583 * Check if the .codegraph directory has valid structure

Callers

nothing calls this directly

Calls 2

getCodeGraphDirFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected