-
-
Notifications
You must be signed in to change notification settings - Fork 38
Description
Details
Currently, husky checks that it's being installed in the repository root, i.e. cwd contains a .git folder.
Some repository contain more than a .net solution, it's not uncommon to have other folders at root such as docs, infra, front-end, etc. In our setup, dotnet solution and .config local tools live in a Source folder, under root.
The issue with this is that:
- Local dotnet tool can't run outside
Sourcebecause they're local and do not exist outside of that folder. - Local tool Husky can't run inside
Sourcebecause it requires.gitin the same folder where it runs.
As 1. and 2. are mutually exclusive, there's no working configuration :(
Note
Husky -- the NPM project that inspired Husky.Net -- has a "How to" for this topic in its documentation:
https://typicode.github.io/husky/how-to.html#project-not-in-git-root-directory
Their solution is simply to change working directory appropriately in install script and hook.
The blocker is that whereas cd .. & husky works in NPM scripts, there's no way parameter to change the working directory in dotnet run, so husky init can't be run in a different cwd.
Suggested solution
Add a --cwd parameter to install command, so that the working directory can be changed before it runs:
dotnet husky install --cwd ../..
The reverse cd command should be inferred automatically (using Path.GetRelativePath) and introduced in hook script so that they run in the correct folder (otherwise dotnet husky & other local .net tool tasks will not be found).