typicode / husky

Git hooks made easy 🐶 woof!
https://typicode.github.io/husky
MIT License
32.35k stars 1.02k forks source link

Husky doesn't run precommit commands, if I have two folders with husky installed in each. #1456

Open rohanasif opened 3 months ago

rohanasif commented 3 months ago

Using Ubuntu 22.04.4, Node 18, Git 2.45.2 and the latest husky. I have a project with the following folder structure.

Project root folder(let's say its "my_project") |- api |- frontend

The root is the git repo as only that contains the .git folder. I have a package.json each in the api and frontend folders with husky installed.

both .husky folders in the api and frontend contain the same content but I tried the "Project not in git root directory" steps and created separate precommit files for both e.g. in the api folder:

cd api npm i npm run test npm run lint npx lint-staged

and in the frontend folder:

cd frontend npm i npm run test npm run lint npx lint-staged

The issue is that only one of these run on committing the project and which one runs depends if I setup husky first in the api folder or frontend folder. If you're facing this issue and found something please let me know. I tested the hooks using the exit 1 strategy and found that husky only runs in one of the folders.

rohanasif commented 3 months ago

For now I have created a husky config in the api folder, removed husky and husky scripts from the frontend folder. And basically configured husky in the api to cd to frontend after running the api folder's scripts and then run frontend's scripts. But still seeking a solution for my issue.