-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure husky (git hooks) in submodules #192
Comments
find-path-to-git-hooks-directory-on-the-shell |
Here's the workaround we use to trick Husky into working with our submodule (on linux) :
The problem is that every developer needs to run the node command. To work around that, we set a yarn postinstall script in our package.json : |
@abrioy It almost works, there is a Thanks for the solution, it works wonderfully ! |
I just switched to husky@5 and it's different to enable hooks in the submodule, In the new version husky modifies the path of the hooks directory, we can do it directly with the git command: cd public && git config core.hooksPath ../.husky This script helps you add the hooks in the main repository and a submodule "postinstall": "husky install && cd public && git config core.hooksPath ../.husky" |
It was a little bit different for me.
module.exports = {
hooks: {
'pre-commit': '<your-precommit-command>',
},
}
|
How can i redo those commands using Windows? |
this works for me very well, thank you very much!!! if you have multiple submodlues you can add a shell script to do this. something like this: package.json
submodule-husky-hook-path.sh
|
this works for me very well, thank you very much!!! #!/usr/bin/env sh
# $ Specify husky of git submodule as the .husky directory of the root directory.
PACKAGES_DIR="$(cd "$(dirname "$0")/../packages" && pwd)"
# Use the find command to get the subdirectory and store the result in the variable
SUBDIRS=$(find "$PACKAGES_DIR" -mindepth 1 -maxdepth 1 -type d)
for dir in $SUBDIRS; do
cd "$dir" || continue
git config core.hooksPath ../../.husky
done |
Since it is a well-known issue, we need to come up with idea, how to make it work
typicode/husky#404
By the way, I do agree with this comment. This is not okay.
typicode/husky#404 (comment)
The text was updated successfully, but these errors were encountered: