Skip to content

Commit

Permalink
Improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
typicode committed Sep 11, 2018
1 parent 94d3d1b commit 42c2fd4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -2,7 +2,8 @@

## Unreleased

* Only show `--no-verify` message for hooks that can be skipped
* Make `--no-verify` message more accurate and only show it for hooks that can be skipped
* Improve error messages

## 1.0.0-rc.13

Expand Down
16 changes: 14 additions & 2 deletions src/installer/index.ts
Expand Up @@ -131,6 +131,10 @@ export function install(
// Checks
if (gitDirOrFile === null) {
console.log("Can't find .git, skipping Git hooks installation.")
console.log(
"Please check that you're in a cloned repository",
"or run 'git init' to create an empty Git repository and reinstall husky."
)
return
}

Expand All @@ -156,6 +160,9 @@ export function install(

if (userPkgDir === null) {
console.log("Can't find package.json, skipping Git hooks installation.")
console.log(
'Please check that your project has a package.json or create it and reinstall husky.'
)
return
}

Expand All @@ -168,9 +175,14 @@ export function install(

if (!fs.existsSync(path.join(resolvedGitDir, 'hooks'))) {
console.log(
`Can't find hooks directory in ${resolvedGitDir}. You can try to fix this error by creating it manually.`
`Can't find hooks directory in ${resolvedGitDir}, skipping Git hooks installation.`
)
console.log(
`Please create ${path.join(
resolvedGitDir,
'hooks'
)} directory and reinstall husky.`
)
console.log('Skipping Git hooks installation.')
return
}

Expand Down

0 comments on commit 42c2fd4

Please sign in to comment.