Skip to content

refactor: conditionally run based on the package manager #743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

Expand Down
Loading