Files
.github
src
bin
keycloakify
tools
octokit-addons
NpmModuleVersion.ts
cliOptions.ts
crawl.ts
downloadAndUnzip.ts
getProjectRoot.ts
grant-exec-perms.ts
isInside.ts
logger.ts
pathJoin.ts
rm.ts
transformCodebase.ts
create-keycloak-email-directory.ts
download-builtin-keycloak-theme.ts
generate-i18n-messages.ts
link_in_test_app.ts
mockTestingResourcesPath.ts
promptKeycloakVersion.ts
tsconfig.json
lib
test
.gitattributes
.gitignore
.prettierignore
.prettierrc.json
CONTRIBUTING.md
LICENSE
README.md
package.json
renovate.json
tsproject.json
yarn.lock
keycloak_theme/src/bin/tools/getProjectRoot.ts

20 lines
465 B
TypeScript

import * as fs from "fs";
import * as path from "path";
function getProjectRootRec(dirPath: string): string {
if (fs.existsSync(path.join(dirPath, "package.json"))) {
return dirPath;
}
return getProjectRootRec(path.join(dirPath, ".."));
}
let result: string | undefined = undefined;
export function getProjectRoot(): string {
if (result !== undefined) {
return result;
}
return (result = getProjectRootRec(__dirname));
}