Closed flo62134 closed 3 years ago
Hey guys, same issue here, lemme show you configuration
package.json
I removed it and reinstall, tried with npm rebuild and still facing same issue hook/pre-commit
--edit
Same issue!
@flo62134 please clarify the issue you are seeing. @pelukron, @Jesseyx what do you mean by "same issue"?
Running husky.sh from the command-line is not how you exercise the hooks so the output given is expected. The contents of pre-commit script under .git/hooks is also expected. Note the leading .
in front of the call to husky.sh inside the pre-commit hook. This sources the script so that basename inside husky.sh produces the name of the hook that called it. By running husky.sh script directly, you are basically asking husky to "run the git hook named husky.sh
" but there is no such hook in git.
The way to run the hooks is by performing git operations. What happens when you commit? What is not working?
I had the same problem on Ubuntu 20 (WSL2).
I fixed it after couple minutes of investigating, the problem was the wrong git hookspath
set during Husky installation.
I think the problem came from this commit https://github.com/typicode/husky/commit/cde7acedb69e224bc4465aa7d131fbddc0a9883b (I never had problem in my previous projects before this commit) and hookspath
value is wrong on some OS (working on macos without problems)
After running git config core.hookspath ".git/hooks"
everything was working.
My problem can be related to this issue.
Thanks a lot @Jerome1337 you fixed my issue with git config core.hookspath ".git/hooks"
!
Hooks are triggered on precommit 👍
git config core.hookspath ".git/hooks"
This doesn't work for me 😢
@alexeyten
Just chiming in here, after struggling with this.
Did this:
npm i husky-init -D
npx husky-init
- You shouldn't need to run npm i
after this, but maybe do it anywaynpm i @commitlint/config-conventional @commitlint/cli -D
#!/bin/sh
# .husky/commit-msg (v7)
# ...
npx --no-install commitlint --edit "$1"
# or
# yarn commitlint --edit $1
module.exports = {
extends: ['@commitlint/config-conventional']
};
Then created a commit and my commit-msg and pre-commit hooks work fine.
The docs are pretty helpful: https://typicode.github.io/husky/#/?id=install
Hi,
I'm trying to use Husky on a personal project of mine. I can't manage to make hooks running.
When mannually running husky.sh, here is the output with the debug option enabled:
This is the content of .git/hooks/pre-commit:
This is an extract from package.json:
I tried:
Running the script .git/hooks/pre-commit myself works fine though. This is the only way to make this work.
My config:
Thanks for your help!