We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Summary I see two use cases for submodules with Husky
Here I focus only on the first case
Context
Steps
mkdir husky_submodule_hooks_from_root; cd husky_submodule_hooks_from_root; git init; pnpm init pnpm install husky; pnpm husky git config --get core.hooksPath => .husky/_ git submodule add [email protected]:typicode/husky.git husky_submodule cd husky_submodule git rev-parse --git-path hooks => .../husky_submodule_hooks_from_root/.git/modules/husky_submodule/hooks git config --get core.hooksPath => nothing
hooksPath
As a workaround I created the script .husky/link-submodules-hooks.sh
.husky/link-submodules-hooks.sh
#!/bin/bash # Create the symlinks .git/modules/<submodule_path>/hooks to .husky/<submodule_paths> git submodule foreach --quiet '\ cd $(git rev-parse --git-path hooks)/.. ;\ mv hooks hooks.bak || true ;\ mkdir -p ../../../../.husky/$path ;\ ln -s ../../../../.husky/$path hooks ;\ ' || true # No blocking if the .git folder is missing (like during deploy)
And run it from my package.json:
package.json
{ "prepare": "husky; ./.husky/link-submodules-hooks.sh" }
Glad to it, I have folders in my .husky directory where i can store my hooks like
.husky
.husky -- submodules-path/ ---- submodule1 ------ pre-commit ------ pre-push ------ ... ---- submodule2 ------ ...
This feature should belong, IMHO, to Husky. Meanwhile, this script may help other Husky users to achieve it!
This use case also answers your message, here #1308 (comment)
Thanks a lot for sharing your work!
The text was updated successfully, but these errors were encountered:
I am using version v9, how do I write the./.husky/link-submodules-hooks.sh file
Sorry, something went wrong.
Just create it and copy the following content as written above
NB: Windows doesn't support symlinks for what I know, I personnaly use Linux
Then add the prepare line to your package Then run npm / yarn or pnpm install
No branches or pull requests
Summary
I see two use cases for submodules with Husky
Here I focus only on the first case
Context
Steps
hooksPath
of the root repo so Husky can't handle submodules hooks.As a workaround I created the script
.husky/link-submodules-hooks.sh
And run it from my
package.json
:Glad to it, I have folders in my
.husky
directory where i can store my hooks likeThis feature should belong, IMHO, to Husky. Meanwhile, this script may help other Husky users to achieve it!
This use case also answers your message, here #1308 (comment)
Thanks a lot for sharing your work!
The text was updated successfully, but these errors were encountered: