I'm setting up a node project with husky
and I want to have a git-hook script run manually, without having to trigger it in git.
Example:
My package.json has the following:
{
...
"scripts": {
"precommit": // something goes here
}
...
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
...
}
If I run npm run precommit
, the lint-staged
hook step runs, WITHOUT the commit actually occurring in git.
Is this possible?
If you want to manually run all pre-commit hooks on a repository, run pre-commit run --all-files . To run individual hooks use pre-commit run <hook_id> . The first time pre-commit runs on a file it will automatically download, install, and run the hook.
Use the --no-verify option to skip git commit hooks, e.g. git commit -m "commit message" --no-verify . When the --no-verify option is used, the pre-commit and commit-msg hooks are bypassed.
It should be possible, since this answer illustrates you can simply call the .git/hooks/pre-commit
So as long as you are calling the hook directly, with its full path, you would run whatever it contains.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With