-
-
Notifications
You must be signed in to change notification settings - Fork 360
Expand file tree
/
Copy pathpre-commit
More file actions
executable file
·61 lines (49 loc) · 1.12 KB
/
pre-commit
File metadata and controls
executable file
·61 lines (49 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
#
# Pre-commit hook that runs Deno tasks:
# - deno task check (type checking)
# - deno task lint (linting)
# - deno task test (tests)
# - deno task fmt (formatting)
#
# If any task fails, the commit is aborted.
echo "Running pre-commit hooks..."
# Store the stashed changes if any
git stash -q --keep-index
# Run deno task check
echo "Running type checking..."
deno task check
CHECK_STATUS=$?
# Run deno task lint
echo "Running linting..."
deno task lint
LINT_STATUS=$?
# Run deno task test
echo "Running tests..."
deno task test
TEST_STATUS=$?
# Run deno task fmt
echo "Running formatter..."
deno task fmt
FMT_STATUS=$?
# Restore the stashed changes
git stash pop -q
# Check if any of the tasks failed
if [ $CHECK_STATUS -ne 0 ]; then
echo "❌ Type checking failed. Commit aborted."
exit 1
fi
if [ $LINT_STATUS -ne 0 ]; then
echo "❌ Linting failed. Commit aborted."
exit 1
fi
if [ $TEST_STATUS -ne 0 ]; then
echo "❌ Tests failed. Commit aborted."
exit 1
fi
if [ $FMT_STATUS -ne 0 ]; then
echo "❌ Formatting failed. Commit aborted."
exit 1
fi
echo "✅ All pre-commit hooks passed!"
exit 0