Reputation: 538
This is my folder file structure. It is an MVC, where the Template.Web
is one of the folders that has to do with the rendering of my Vue app. The rest of the folders are not provided as they are irrelevant.
/parent repo folder/ # Root of the Git repository
├── .git/ # Git directory
├── src/ # Source directory
│ └── Template.Web/ # Project directory
│ └── src/ # Nested source directory
│ ├── .husky/ # Husky hooks directory
│ │ └── pre-commit # Pre-commit hook script
│ ├── components/ # Components directory
│ │ └── nav-bar/ # Example component directory
│ │ └── nav-bar.vue # Example Vue component
│ └── package.json # Project's package.json file
In the package.json
prepare script I have tried:
"prepare": "cd ../toTheParentRepo && husky install src/Template.Web/src/.husky",
"prepare": "husky install",
and a lot of other commands.
In the pre-commit file I am echoing, in order to see if I get something in the console, when running npm run prepare
and it appears that I am getting nothing, which might be the issue. So maybe the file is not even located properly. You can see that I am trying to go to the parent folder, but I have also tried it without cd
.
#!/usr/bin/env sh
echo "Pre-commit hook starting"
set -e
. "$(dirname -- "$0")/_/husky.sh"
echo "Navigating to project directory"
cd /src/Template.Web/src (Maybe the path is incorrect but doesnt even matter at this point since it does not even echo)
echo "Running type-check"
npm run type-check
echo "Running lint-staged"
npx lint-staged
echo "Pre-commit hook finished"
The type-check
, lint-staged
, etc. are scripts that I have set up correctly, so no issues with them.
I have read many articles like this one https://scottsauber.com/2021/06/01/using-husky-git-hooks-and-lint-staged-with-nested-folders/
Upvotes: 0
Views: 234