![]() ![]() Husky makes it possible to use githooks as if they are npm scripts and configurable from your package.json. So, we’ll be using an easy way out Husky. We can configure and write hooks in these files, but it’s a cumbersome task. We will be using the pre-commit hook to auto-format our code before a commit takes place. ![]() Or, if you’re writing a new script from scratch, you can simply add a new file matching one of the above filenames, minus the. To “ install” a hook, all you have to do is remove the. sample extension prevents them from executing by default. ![]() These represent most of the available hooks, but the. You can also check the hooks inside your git project by going into the hidden. They let you customize Git’s internal behaviour and trigger customizable actions at key points in the development life cycle.Ī full list of the available hooks can be found here Types of Git Hooks. But, what are hooks now? Git hooks are scripts that run automatically every time a particular event occurs in a Git repository. Let’s see how we can configure our project to make that possible.įirst of all, git provides us with hooks. This is a general solution irrespective of the editor. We’ll be doing formatting with prettier before committing the code to Git. So, we had to find a solution which works for all despite the code editor. This leads to unnecessary conflicts while rebasing the code and creates a mess. When you are working on a project with multiple developers, you always have the issue of formatting the code as some work on VSCode and some on WebStorm, some have configured auto formatting while others don’t, some people have configured their tab size to be 4 while others have 2. ![]()
0 Comments
Leave a Reply. |