File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -17,10 +17,19 @@ check_pnpm_files() {
17
17
}
18
18
19
19
# List of all check functions
20
- CHECK_FUNCTIONS=(
21
- "check_npm_files"
20
+ # Detect the lock file to determine the package manager
21
+ if [ -f "pnpm-lock.yaml" ]; then
22
+ CHECK_FUNCTIONS=(
22
23
"check_pnpm_files"
23
24
)
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
24
33
25
34
# Check for changes in specified files before pushing and run corresponding commands
26
35
## Get the upstream branch
@@ -37,18 +46,18 @@ if [ -z "$UPSTREAM" ]; then
37
46
fi
38
47
39
48
## Get the list of files changed between upstream and HEAD
40
- FILES=$(git diff --name-only $UPSTREAM..HEAD)
49
+ FILES=$(git diff --name-only " $UPSTREAM" ..HEAD)
41
50
42
51
## Check each pattern and run corresponding command
43
52
for check_function in "${CHECK_FUNCTIONS[@]}"; do
44
53
# Call the check function to set variables
45
54
$check_function
46
-
55
+
47
56
if echo "$FILES" | grep -qE "$PATTERN"; then
48
57
echo "Detected changes in $DESCRIPTION"
49
58
50
59
## Run the corresponding command
51
- eval " $COMMAND"
60
+ $COMMAND
52
61
53
62
if [ $? -ne 0 ]; then
54
63
echo "Command failed: $COMMAND. Aborting push."
You can’t perform that action at this time.
0 commit comments