-
Notifications
You must be signed in to change notification settings - Fork 76
Prettier setting in config file in the repo now apply to all contributors code automatically #204
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
Conversation
…tors code automatically
@AyanDas348 , thank you again, can you help me to understand where the script is exactly? |
@lugenx under ./git/hooks/pre-commit. The folder is hidden by default so you might need to turn on hidden folders in editors like VS Code to access it. It basically runs a script that says that before committing it will make changes to the files and folders in the folder:
|
thank you for the explanation, @AyanDas348. you're right that the |
@lugenx Whenever any contributor/users clone this repository they will also get the hooks from ./git/hooks cloned into their directory. When they commit it will apply the prettier changes as mentioned in .prettierrc.json file. I have made the pre-commit an executable so it runs when contributors make a commit. |
Hey @lugenx did you have the chance to take a look at this PR? |
hey, @AyanDas348 didn't have a chance yet unfortunately. i should have some time today or tomorrow. thank you for your patience. |
hi @AyanDas348 , I cloned your branch, and this is how the .git/hooks folder looks like: And this is the inside of precommit-sample file: can you help me find out your script? Thank you |
Hey @lugenx I have noticed my script has not been cloned. There is some issue with making the pre-commit hook executable and cloned. I'll look into this and start working out a new solution. Thanks for your patience. |
I will close the pull request and open a new one when I have resolved it. I'll make sure to reclone the repo on a different system to test if the pre-commit hook is working or not. |
sounds good, @AyanDas348 , thank you so much for looking into this, if you have any questions or just want to discuss while figuring this out, you can reach out to me or @tsimian in our discord chat. you can join the discord server through the link in the readme file if you didn't already. |
Thanks @lugenx I'll join the discord and let you know if I have a working solution. |
#94 Prettier setting in config file in the repo now apply to all contributors code automatically
-Added script in ./git/hooks/pre-commit:
Run Prettier on all staged files
npx prettier --write --config .prettierrc.json --ignore-path .gitignore --ignore-unknown .
-Made the script an executable file using:
For windows: icacls .git/hooks/pre-commit /grant:r "%USERNAME%":F
For Unix systems(Linux, macOS): git update-index --chmod=+x .git/hooks/pre-commit