Skip to content

Commit 6fb1f4c

Browse files
committed
feat: add build and test checks to pre-commit hooks
1 parent c157e10 commit 6fb1f4c

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

.husky/pre-commit

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
echo "Running pre-commit checks..."
5+
6+
# Run lint-staged for code formatting and linting
7+
echo "Running lint-staged..."
18
pnpm lint-staged
9+
10+
# Run build to ensure project builds successfully
11+
echo "Running build checks..."
12+
pnpm build || {
13+
echo "❌ Build failed. Please fix the build errors before committing."
14+
exit 1
15+
}
16+
17+
# Run tests to ensure all tests pass
18+
echo "Running tests..."
19+
pnpm test || {
20+
echo "❌ Tests failed. Please fix the failing tests before committing."
21+
exit 1
22+
}
23+
24+
echo "✅ All checks passed!"

CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ This project and everyone participating in it is governed by our Code of Conduct
8787

8888
- `pnpm lint`: Lints the staged files using ESLint
8989
- `pnpm format`: Formats the staged files using Prettier
90+
- `pnpm build`: Ensures the project builds successfully
91+
- `pnpm test`: Ensures all tests pass
9092

91-
If either of these commands fails due to linting errors or formatting issues, the commit will be aborted. Please fix the reported issues and try committing again.
93+
If any of these commands fails, the commit will be aborted. Please fix the reported issues and try committing again.
9294

9395
You can also run the lint and format commands manually at any time:
9496

@@ -164,4 +166,4 @@ This project and everyone participating in it is governed by our Code of Conduct
164166
3. Update changelog entries
165167
4. Tag releases appropriately
166168

167-
Thank you for contributing to MyCoder! 👍
169+
Thank you for contributing to MyCoder! 👍

0 commit comments

Comments
 (0)