I’ve always loved the concept of git hooks
, but it’s setup has always troubled me as being snowflaky
.
Sharing hooks across a development team was awkward and there was no Ubiquitous
Language.
After struggling with bespoke solutions in the lingua franca of bash,
I rolled my own solutions which has been lost (fortunately) to Father Time.
My Eureka moment happened last week when I came across commitlint
and the Conventional Commits spec
(an admirable way to manage releases and make commits more readable).
In trying to integrate Conventional Commits to my website,
I’ve come across a solution that works perfect for me.
The current setup uses husky
as a dev-dependency in package.json
which sets up a commit-msg
hook as follows:
The great part of this setup is that it ties everything into a single package.json
file.
The npm eco-system is a cesspool when it comes to security but it does make developer tooling a breeze.
The community converging on using a single package.json
is a god-send, over the alternative of a bunch of .rc files spewed all across; adding git hooks
is the natural evolution to the puzzle.
It’s great how sometimes your problems solve themselves if you let them be for years.