import * as Path from "path";
import * as Fs from "fs";
export class PathUtil {
// ========================================================================================
/** 프로젝트 루트 경로 찾기
*/// ======================================================================================
public static GetProjectRootPath(startPath: string = __dirname): string {
let currentPath = startPath;
while (currentPath !== Path.dirname(currentPath)) {
if (Fs.existsSync(Path.join(currentPath, "package.json"))) {
return currentPath;
}
currentPath = Path.dirname(currentPath);
}
throw new Error("프로젝트 루트를 찾을 수 없습니다 (package.json이 없음)");
}
}