export function findGitRoot()

in contribs/just-repo-utils/src/repoInfo.ts [30:41]


export function findGitRoot(cb?: FindRootCallback, options?: RepoInfoOptions): string {
  let cwd = (options && options.cwd) || process.cwd();
  const root = path.parse(cwd).root;

  while (cwd !== root) {
    if ((cb && cb(cwd)) || fse.existsSync(path.join(cwd, '.git'))) {
      return cwd;
    }
    cwd = path.dirname(cwd);
  }
  throw 'No repository root found!';
}