Support for Projects with .git Directory in a Nested Parent Directory #1400
Unanswered
ShanteshSindgi
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a project structure where the .git directory is located three levels up from the root directory where Husky is installed. The current setup requires manual navigation to the .git directory (cd ../../../) before running husky install to ensure Husky hooks are correctly set up. Additionally, for the hooks themselves (e.g., pre-commit), there is a need to navigate back to the nested project directory, complicating the script and making it error-prone.
Current Workaround:
In the prepare script in package.json, I've included a command to navigate to the .git directory (cd ../../../) and then run husky install. Similarly, in the Husky hook scripts (e.g., .husky/pre-commit), I find myself needing to include commands to navigate back to the project directory where the actual code and scripts reside.
Desired Solution:
I'm looking for a solution or configuration option in Husky that allows it to automatically detect the location of the .git directory without requiring manual directory navigation commands in the setup and hook scripts. This would streamline the process and reduce the potential for errors, especially in complex project structures.
Questions:
Is there an existing configuration option in Husky to handle this scenario?
If not, could a feature be considered for future releases to support automatic detection of .git directory locations, especially when they are not in the root directory of the project where Husky is installed?
Are there recommended practices for handling such project structures with Husky that I might have overlooked?
Thank you for considering this issue. Any guidance or suggestions on how to better handle this setup with Husky would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions