You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context
Please describe your issue and provide some context:
Running husky on mac in zsh shell
I created post-checkout hook which receives two inputs from git -
the ref of the previous HEAD, the ref of the new HEAD
I use this to check for diff in package.json and notify if package.json has changed when you checkout
This hook runs fine if I add it in .git/hooks folder but when I try to add it to husky, husky runs the hook without providing the two inputs HEADs that git does and the hook fails.
Here is the hook:
# Checks if package.json has been changed when you checkout a branch# If changed, then it will print a warning to nudge the user to reinstall packages.# Define colors
RED='\033[0;31m'
YELLOW='\033[0;33m'
PACKAGE_ICON='📦'
ARROW_ICON='➜'
PREV_COMMIT=$1
POST_COMMIT=$2echo$PACKAGE_ICONecho$PREV_COMMIT# prints empty line if run via huskyecho$POST_COMMIT# prints empty line if run via husky# Compare package.json between commits
DIFF=$(git diff --name-only "$PREV_COMMIT".."$POST_COMMIT"| grep "package.json")# If package.json has changed, display warningif [[ -n"$DIFF" ]];thenecho"${YELLOW}===============================\n"echo"${YELLOW}${PACKAGE_ICON} package.json changes detected ${PACKAGE_ICON}${NC}\n"echo"${YELLOW}==============================="
git diff --unified=0 "$PREV_COMMIT".."$POST_COMMIT" package.json
fi
Screenshot of the error
The text was updated successfully, but these errors were encountered:
Troubleshoot
https://typicode.github.io/husky/troubleshoot.html
If you're migrating from husky 4, see:
https://typicode.github.io/husky/migrate-from-v4.html
Context
Please describe your issue and provide some context:
Running husky on mac in zsh shell
I created post-checkout hook which receives two inputs from git -
I use this to check for diff in package.json and notify if package.json has changed when you checkout
This hook runs fine if I add it in .git/hooks folder but when I try to add it to husky, husky runs the hook without providing the two inputs HEADs that git does and the hook fails.
Here is the hook:
Screenshot of the error
The text was updated successfully, but these errors were encountered: