From 2397cc01538c02b72a7b0993c8e6fc28fefba1f9 Mon Sep 17 00:00:00 2001 From: khai96_ Date: Tue, 3 Mar 2026 00:57:14 +0700 Subject: [PATCH] chore(git): skip hooks if runner isn't found --- .husky/commit-msg | 15 ++++++++++++++- .husky/pre-push | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.husky/commit-msg b/.husky/commit-msg index f5f8917b72..fb0bea1b3c 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1 +1,14 @@ -pnpm commitlint --edit --config=commitlint.config.cjs +#! /usr/bin/env sh +set -o errexit -o nounset + +runner=$( + command -v pnpm || + command -v npm || + true +) + +if [ -n "$runner" ]; then + exec "$runner" commitlint --edit --config=commitlint.config.cjs +else + echo 'Neither pnpm nor npm was found. Skip linting.' >&2 +fi diff --git a/.husky/pre-push b/.husky/pre-push index 701e0fbce4..6a8fb70d0f 100755 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1 +1,14 @@ -pnpm run lint --quiet +#! /usr/bin/env sh +set -o errexit -o nounset + +runner=$( + command -v pnpm || + command -v npm || + true +) + +if [ -n "$runner" ]; then + exec "$runner" run lint --quiet +else + echo 'Neither pnpm nor npm was found. Skip linting.' >&2 +fi