diff --git a/src/configuration.ts b/src/configuration.ts index ae82465c..52a81377 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -4,6 +4,7 @@ const execa = require("execa"); const hostedGitInfo = require("hosted-git-info"); import ConfigurationError from "./configuration-error"; +import { getRootPath } from "./git"; export interface Configuration { repo: string; @@ -20,9 +21,7 @@ export interface ConfigLoaderOptions { } export function load(options: ConfigLoaderOptions = {}): Configuration { - let cwd = process.cwd(); - let rootPath = execa.sync("git", ["rev-parse", "--show-toplevel"], { cwd }).stdout; - + let rootPath = getRootPath(); return fromPath(rootPath, options); } diff --git a/src/git.ts b/src/git.ts index 0be7c7f7..bdaa4fe0 100644 --- a/src/git.ts +++ b/src/git.ts @@ -1,5 +1,10 @@ const execa = require("execa"); +export function getRootPath() { + const cwd = process.cwd(); + return execa.sync("git", ["rev-parse", "--show-toplevel"], { cwd }).stdout; +} + export async function changedPaths(sha: string): Promise { const result = await execa("git", ["show", "-m", "--name-only", "--pretty=format:", "--first-parent", sha]); return result.stdout.split("\n");