Skip to content

Commit 19ba9c1

Browse files
authored
Update pre-push
1 parent e6e7b7c commit 19ba9c1

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

.husky/pre-push

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,19 @@ check_pnpm_files() {
1717
}
1818

1919
# List of all check functions
20-
CHECK_FUNCTIONS=(
21-
"check_npm_files"
22-
"check_pnpm_files"
20+
# Detect the lock file to determine the package manager
21+
if [ -f "pnpm-lock.yaml" ]; then
22+
CHECK_FUNCTIONS=(
23+
"check_pnpm_files"
2324
)
25+
elif [ -f "package-lock.json" ]; then
26+
CHECK_FUNCTIONS=(
27+
"check_npm_files"
28+
)
29+
else
30+
echo "No lock file detected for pnpm or npm. Aborting pre-push checks."
31+
exit 1
32+
fi
2433

2534
# Check for changes in specified files before pushing and run corresponding commands
2635
## Get the upstream branch
@@ -43,7 +52,7 @@ FILES=$(git diff --name-only $UPSTREAM..HEAD)
4352
for check_function in "${CHECK_FUNCTIONS[@]}"; do
4453
# Call the check function to set variables
4554
$check_function
46-
55+
4756
if echo "$FILES" | grep -qE "$PATTERN"; then
4857
echo "Detected changes in $DESCRIPTION"
4958

0 commit comments

Comments
 (0)