Skip to content

Commit

Permalink
improve error message if git command fails (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
typicode authored Jul 16, 2019
1 parent a694261 commit 3b2d7e7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 28 deletions.
21 changes: 7 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,17 @@
},
"homepage": "https://github.com/typicode/husky#readme",
"dependencies": {
"chalk": "^2.4.2",
"cosmiconfig": "^5.2.1",
"execa": "^1.0.0",
"get-stdin": "^7.0.0",
"is-ci": "^2.0.0",
"opencollective-postinstall": "^2.0.2",
"pkg-dir": "^4.2.0",
"please-upgrade-node": "^3.1.1",
"read-pkg": "^5.1.1",
"run-node": "^1.0.0",
"slash": "^3.0.0",
"opencollective-postinstall": "^2.0.2"
"slash": "^3.0.0"
},
"devDependencies": {
"@types/cosmiconfig": "^5.0.3",
Expand Down
5 changes: 3 additions & 2 deletions src/installer/bin.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import chalk from 'chalk'
import isCI from 'is-ci'
import path from 'path'
import debug from '../debug'
Expand Down Expand Up @@ -34,6 +35,6 @@ try {
uninstall(absoluteGitDir, huskyDir)
}
} catch (error) {
console.log(error.message.trim())
console.log(`husky > Failed to ${action}`)
console.log(chalk.red(error.message.trim()))
console.log(chalk.red(`husky > Failed to ${action}`))
}
15 changes: 5 additions & 10 deletions src/installer/gitRevParse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@ export default function(): {
topLevel: string
absoluteGitDir: string
} {
let result
try {
result = execa.sync('git', [
'rev-parse',
'--show-toplevel',
'--absolute-git-dir'
])
} catch (error) {
throw new Error(error.stderr)
}
const result = execa.sync('git', [
'rev-parse',
'--show-toplevel',
'--absolute-git-dir'
])

const [topLevel, absoluteGitDir] = result.stdout
.trim()
Expand Down

0 comments on commit 3b2d7e7

Please sign in to comment.