Skip to content

Commit

Permalink
Update to handle failed prepare-commit-msg (#138)
Browse files Browse the repository at this point in the history
* Update to handle failed prepare-commit-msg

* Added more accurate error message for `prepare-commit-msg` hook

* fix coding style to match standardjs.
  • Loading branch information
FJunior225 authored and typicode committed Jun 17, 2017
1 parent b136173 commit 3ba3c34
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/index.js
Expand Up @@ -125,8 +125,13 @@ function getHookScript (hookName, relativePath, cmd) {

// Can't find npm message
var npmNotFound = '> husky - Can\'t find npm in PATH. Skipping ' + cmd + ' script in package.json'

var failedMessage
var scriptName = hookName.replace(/-/g, '')
if (hookName === 'prepare-commit-msg') {
failedMessage = ' echo "> husky - ' + hookName + ' hook failed (cannot be suppressed by --no-verify due to Git specs)"'
} else {
failedMessage = ' echo "> husky - ' + hookName + ' hook failed (add --no-verify to bypass)"'
}
arr = arr.concat([
// Test if npm is in PATH
'command_exists npm || {',
Expand All @@ -145,7 +150,7 @@ function getHookScript (hookName, relativePath, cmd) {
'export GIT_PARAMS="$*"',
'npm run -s ' + cmd + ' || {',
' echo',
' echo "> husky - ' + hookName + ' hook failed (add --no-verify to bypass)"',
failedMessage,
' echo "> husky - to debug, use \'npm run ' + scriptName + '\'"',
' exit 1',
'}',
Expand Down

0 comments on commit 3ba3c34

Please sign in to comment.