Spaces:
Paused
Paused
File size: 392 Bytes
de36cdc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import { existsSync } from "fs";
import { join, dirname } from "path";
export function findRepoRoot(startPath: string): string {
let currentPath = startPath;
while (currentPath !== "/") {
if (existsSync(join(currentPath, "package.json"))) {
return currentPath;
}
currentPath = dirname(currentPath);
}
throw new Error("Could not find repository root (no package.json found)");
}
|