From 01ca29fc0117df7c39542ee5a5198a0ebc20a854 Mon Sep 17 00:00:00 2001 From: Yury Shkoda Date: Thu, 20 May 2021 08:22:40 +0300 Subject: [PATCH] feat(git): enabled git hook enforcing conventional commits --- .git-hooks/commit-msg | 18 ++++++++++++++++++ package.json | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100755 .git-hooks/commit-msg diff --git a/.git-hooks/commit-msg b/.git-hooks/commit-msg new file mode 100755 index 0000000..e0297de --- /dev/null +++ b/.git-hooks/commit-msg @@ -0,0 +1,18 @@ +#!/bin/sh +RED="\033[1;31m" +GREEN="\033[1;32m" + +# Get the commit message (the parameter we're given is just the path to the +# temporary file which holds the message). +commit_message=$(cat "$1") + +if (echo "$commit_message" | grep -Eq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([a-z \-]+\))?!?: .+$") then + echo "${GREEN} ✔ Commit message meets Conventional Commit standards" + exit 0 +fi + +echo "${RED}❌ Commit message does not meet the Conventional Commit standard!" +echo "An example of a valid message is:" +echo " feat(login): add the 'remember me' button" +echo "ℹ More details at: https://www.conventionalcommits.org/en/v1.0.0/#summary" +exit 1 \ No newline at end of file diff --git a/package.json b/package.json index eb0f0f5..cf3515c 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "prepublishOnly": "cp -r ./build/* . && rm -rf ./build", "postpublish": "git clean -fd", "semantic-release": "semantic-release", - "typedoc": "typedoc" + "typedoc": "typedoc", + "postinstall": "[ -d .git ] && git config core.hooksPath ./.git-hooks || true" }, "publishConfig": { "access": "public"