With husky you can execute a script on a git hook
There a dev dependencies inside the project of husky.
After npm i
you have only to attach husky to git for the first time with:
npm run prepare
or husky install
Inside .husky
directory you can find a script named like a git hook (without any extension).
It's will be called when git start that hook.
commit-msg
Before commit it check if the message it follow the rules inenforce-commit-message.sh
pre-commit
Before commit it runlint-staged
(configured in.lintstagedrc
) for lint and prettify the codebase and alsoenforce-branch-name.sh
pre-push
Before push it check if build failsenforce-branch-name.sh
and lint the app
List of hook you can configure:
- applypatch-msg
- pre-push
- commit-msg
- pre-rebase
- post-update
- prepare-commit-msg
- pre-applypatch
- update
- pre-commit