2021-02-28 18:40:57 +01:00
|
|
|
import * as fs from "fs";
|
|
|
|
import * as path from "path";
|
|
|
|
|
2024-02-11 20:15:18 +01:00
|
|
|
function getThisCodebaseRootDirPath_rec(dirPath: string): string {
|
2022-07-29 23:10:35 +02:00
|
|
|
if (fs.existsSync(path.join(dirPath, "package.json"))) {
|
2021-02-28 18:40:57 +01:00
|
|
|
return dirPath;
|
|
|
|
}
|
2024-02-11 20:15:18 +01:00
|
|
|
return getThisCodebaseRootDirPath_rec(path.join(dirPath, ".."));
|
2021-02-28 18:40:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
let result: string | undefined = undefined;
|
|
|
|
|
2024-02-11 20:15:18 +01:00
|
|
|
export function getThisCodebaseRootDirPath(): string {
|
2021-02-28 18:40:57 +01:00
|
|
|
if (result !== undefined) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2024-02-11 20:15:18 +01:00
|
|
|
return (result = getThisCodebaseRootDirPath_rec(__dirname));
|
2021-10-11 21:35:40 +02:00
|
|
|
}
|