Write a custom script to change the git hooks path
The best option seemed like a custom bash script. The script identifies if the engineer has Git version >=2.9 because the simplest command requires such. After the check, the script runs the appropriate command to set git's hook location local to this project.
I've also created an npm script in package.json for setup:gitHooks that makes the hooks executable and runs that script mentioned above. I've also added a setup command to set up the hooks and run npm install as a basic setup for this repo.
In this process, I've also migrated the ESLint config, since our previous implementation is now deprecated.
Updated ESLint and created a git hook that enables autoformatting on git commit, focused on the following file formats:
Background: The .git file cannot be committed, so we needed to create a new place to store custom hooks. The approaches:
The best option seemed like a custom bash script. The script identifies if the engineer has Git version >=2.9 because the simplest command requires such. After the check, the script runs the appropriate command to set git's hook location local to this project.
I've also created an npm script in package.json for
setup:gitHooks
that makes the hooks executable and runs that script mentioned above. I've also added asetup
command to set up the hooks and runnpm install
as a basic setup for this repo.In this process, I've also migrated the ESLint config, since our previous implementation is now deprecated.