Last active
July 14, 2020 08:54
-
-
Save szkrd/47e9e7509102981d6229bb3b597e1186 to your computer and use it in GitHub Desktop.
force install husky (probably v4.x only)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function addHook() { | |
echo -e "#!/bin/sh\n# husky" > .git/hooks/$1 | |
echo '. "$(dirname "$0")/husky.sh"' >> .git/hooks/$1 | |
chmod +x .git/hooks/$1 | |
} | |
DIRNAME="$(basename "${PWD}")" | |
if [ "${DIRNAME}" = 'server' ] || [ "${DIRNAME}" = 'client' ]; then echo "Do not run this script in the server/client subdir!"; exit 1; fi | |
if [ ! -f ./node_modules/husky/package.json ]; then echo "Project has no husky?"; exit 2; fi | |
if [ ! -d ./.git/hooks ]; then echo "Folder not git tracked?"; exit 2; fi | |
rm -f .git/hooks/*.sample | |
addHook applypatch-msg | |
addHook commit-msg | |
addHook post-applypatch | |
addHook post-checkout | |
addHook post-commit | |
addHook post-merge | |
addHook post-rewrite | |
addHook post-update | |
addHook pre-applypatch | |
addHook pre-auto-gc | |
addHook pre-commit | |
addHook pre-merge-commit | |
addHook pre-push | |
addHook pre-rebase | |
addHook prepare-commit-msg | |
addHook push-to-checkout | |
addHook sendemail-validate | |
echo -e "packageManager=npm\ncd ." > .git/hooks/husky.local.sh | |
cp -f node_modules/husky/sh/husky.sh ./.git/hooks/ | |
echo DONE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment