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

Function ensureSubdirectory

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

Source from the content-addressed store, hash-verified

1137 * Ensure a subdirectory exists within .codegraph
1138 */
1139export function ensureSubdirectory(projectRoot: string, subdirName: string): string {
1140 if (subdirName.includes('..') || subdirName.includes(path.sep) || subdirName.includes('/')) {
1141 throw new Error(`Invalid subdirectory name: ${subdirName}`);
1142 }
1143
1144 const subdirPath = path.join(getCodeGraphDir(projectRoot), subdirName);
1145
1146 if (!fs.existsSync(subdirPath)) {
1147 fs.mkdirSync(subdirPath, { recursive: true });
1148 }
1149
1150 return subdirPath;
1151}
1152
1153/**
1154 * Check if the .codegraph directory has valid structure

Callers

nothing calls this directly

Calls 2

getCodeGraphDirFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected