Skip to content

Commit

Permalink
Fix Husky
Browse files Browse the repository at this point in the history
  • Loading branch information
joao Felipe Santoro Pinto committed Feb 25, 2021
1 parent 649d371 commit 7ba8c03
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
30 changes: 30 additions & 0 deletions .husky/_/husky.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh
if [ -z "$husky_skip_init" ]; then
debug () {
[ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1"
}

readonly hook_name="$(basename "$0")"
debug "starting $hook_name..."

if [ "$HUSKY" = "0" ]; then
debug "HUSKY env variable is set to 0, skipping hook"
exit 0
fi

if [ -f ~/.huskyrc ]; then
debug "sourcing ~/.huskyrc"
. ~/.huskyrc
fi

export readonly husky_skip_init=1
sh -e "$0" "$@"
exitCode="$?"

if [ $exitCode != 0 ]; then
echo "husky - $hook_name hook exited with code $exitCode (error)"
exit $exitCode
fi

exit 0
fi
5 changes: 5 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint --fix
yarn test --findRelatedTests --bail
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "./node_modules/.bin/eslint src --max-warnings=0",
"lint": "./node_modules/.bin/eslint ./pages/posts/* --max-warnings=0",
"test": "jest",
"test:watch": "yarn test --watchAll",
"predeploy": "npm run build",
Expand Down Expand Up @@ -45,12 +45,7 @@
"jest-styled-components": "^7.0.3",
"lint-staged": "^10.5.1",
"prettier": "2.1.2",
"typescript": "^4.2.2"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
"typescript": "^4.2.0"
},
"lint-staged": {
"src/**/*": [
Expand Down

0 comments on commit 7ba8c03

Please sign in to comment.