Skip to content

Commit

Permalink
chore: migrate to husky v7
Browse files Browse the repository at this point in the history
  • Loading branch information
vladholubiev committed Mar 7, 2022
1 parent 1d833dd commit 3c66f33
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ yarn.lock
*.log
.DS_Store
globalConfig.json
!.husky/_/husky.sh
31 changes: 31 additions & 0 deletions .husky/_/husky.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh
if [ -z "$husky_skip_init" ]; then
debug () {
if [ "$HUSKY_DEBUG" = "1" ]; then
echo "husky (debug) - $1"
fi
}

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)"
fi

exit $exitCode
fi
3 changes: 3 additions & 0 deletions .husky/post-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
git update-index --again
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn lint-staged
10 changes: 2 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
"test": "jest",
"test:repl": "MONGO_MEMORY_SERVER_FILE=jest-mongodb-config-repl.js jest"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"post-commit": "git update-index --again"
}
},
"lint-staged": {
"*.{html,md,yml}": [
"prettier --write",
Expand All @@ -50,8 +44,8 @@
"devDependencies": {
"@shelf/eslint-config": "1.5.0",
"@shelf/prettier-config": "1.0.0",
"eslint": "8.10.0",
"husky": "4.3.8",
"eslint": "7.32.0",
"husky": "7.0.4",
"jest": "27.5.1",
"lint-staged": "12.3.5",
"mongodb": "4.2.2",
Expand Down

0 comments on commit 3c66f33

Please sign in to comment.