From ec7104dea669196d1109803da5233517849fa5b4 Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Sat, 2 Aug 2025 03:29:09 +0200 Subject: [PATCH] refactor: conditionally run based on the package manager --- .husky/pre-push | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.husky/pre-push b/.husky/pre-push index cca90f313..178789727 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -17,10 +17,19 @@ check_pnpm_files() { } # List of all check functions -CHECK_FUNCTIONS=( - "check_npm_files" - "check_pnpm_files" +# Detect the lock file to determine the package manager +if [ -f "pnpm-lock.yaml" ]; then + CHECK_FUNCTIONS=( + "check_pnpm_files" ) +elif [ -f "package-lock.json" ]; then + CHECK_FUNCTIONS=( + "check_npm_files" + ) +else + echo "No lock file detected for pnpm or npm. Aborting pre-push checks." + exit 1 +fi # Check for changes in specified files before pushing and run corresponding commands ## Get the upstream branch @@ -43,7 +52,7 @@ FILES=$(git diff --name-only $UPSTREAM..HEAD) for check_function in "${CHECK_FUNCTIONS[@]}"; do # Call the check function to set variables $check_function - + if echo "$FILES" | grep -qE "$PATTERN"; then echo "Detected changes in $DESCRIPTION"