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?
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?
Share Improve this question asked Nov 14, 2019 at 23:03 n8jadamsn8jadams 1,1653 gold badges12 silver badges22 bronze badges 3 |2 Answers
Reset to default 16It 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 pre-commit
is installed globally, you can just run this in the terminal:
pre-commit run --all-files
lint-staged
command,"precommit": "lint-staged"
– hoangdv Commented Nov 15, 2019 at 8:53bash .git/hooks/pre-commit
) – n8jadams Commented Nov 15, 2019 at 16:00npx lint-staged
works for me. – tolkinski Commented May 7, 2024 at 19:27