Skip to content
New issue

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

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

Open
rohanasif opened this issue Jun 8, 2024 · 1 comment

Comments

@rohanasif
Copy link

rohanasif commented Jun 8, 2024

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant