diff --git a/src/installer/gitRevParse.ts b/src/installer/gitRevParse.ts index 3ce9e5c42..26a146c7b 100644 --- a/src/installer/gitRevParse.ts +++ b/src/installer/gitRevParse.ts @@ -9,13 +9,17 @@ export type GitRevParseResult = { export function gitRevParse(cwd = process.cwd()): GitRevParseResult { // https://github.com/typicode/husky/issues/580 // https://github.com/typicode/husky/issues/587 - const result = cp.spawnSync( + const { status, stderr, stdout } = cp.spawnSync( 'git', ['rev-parse', '--show-prefix', '--git-common-dir'], { cwd } ) - const [prefix, gitCommonDir] = result.stdout + if (status !== 0) { + throw new Error(stderr.toString()) + } + + const [prefix, gitCommonDir] = stdout .toString() .split('\n') .map(s => s.trim())