From 1acef7d8a5966058d28e549a7c1bfae1cb677ec5 Mon Sep 17 00:00:00 2001 From: verytactical <186486509+verytactical@users.noreply.github.com> Date: Mon, 28 Oct 2024 16:18:17 +0400 Subject: [PATCH] build: remove commit hook for git-cz "Prepare commit message" hook runs not only on commit, but also on a variety of other git tasks such as rebase and merge, sometimes in an automated way from IDE (Jetbrains IDEs do that). git-cz utility wasn't built with this in mind, and leads to bad developer experience. We can use already existing `npm run commit` script for this. Also `"prepare"` npm hook runs when a package is packaged (`npm pack`), and `husky` is intended to be run on install. --- .husky/prepare-commit-msg | 14 -------------- package.json | 2 +- 2 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 .husky/prepare-commit-msg diff --git a/.husky/prepare-commit-msg b/.husky/prepare-commit-msg deleted file mode 100644 index 97d8e9a..0000000 --- a/.husky/prepare-commit-msg +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -# Check if commit message is provided with -m flag -COMMIT_MSG_FILE=$1 -COMMIT_SOURCE=$2 - -# Check if commit is being created from the message source (e.g., with `git commit -m`) -if echo "$HUSKY_GIT_PARAMS" | grep -qE '^-m\s'; then - if [ "$COMMIT_SOURCE" = "message" ]; then - exit 0 - fi -fi - -exec < /dev/tty && npx git-cz --hook || true diff --git a/package.json b/package.json index 62194ca..fcc8fd9 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "lint": "next lint", "format:check": "prettier --check --ignore-path .gitignore .", "format:fix": "prettier --write --ignore-path .gitignore .", - "prepare": "husky", + "postinstall": "husky", "commit": "git-cz" }, "config": {