Skip to content

Commit 48c4463

Browse files
committed
chore: make pre-commit hook fail on warnings
1 parent 966456f commit 48c4463

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

.husky/pre-commit

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
1-
npm run build
1+
#!/bin/sh
2+
3+
# Run build and capture output
4+
output=$(npm run build 2>&1)
5+
exit_code=$?
6+
7+
# Display the output
8+
echo "$output"
9+
10+
# Fail if build command failed
11+
if [ $exit_code -ne 0 ]; then
12+
exit $exit_code
13+
fi
14+
15+
# Fail if warnings were produced
16+
if echo "$output" | grep -qi "warning"; then
17+
echo ""
18+
echo "❌ Build produced warnings - commit blocked"
19+
echo "Please fix the warnings above before committing."
20+
exit 1
21+
fi
22+
23+
echo "✅ Build passed with no warnings"

0 commit comments

Comments
 (0)