Merge pull request #1519 from PR0M3TH3AN/setup-pre-commit-hook-4628620864299579628

Add pre-commit hook setup script and documentation
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-01-22 17:39:57 -05:00
commit cef2de32e4
2 files changed
+44

No files matched your search

+6
View File
@@ -74,6 +74,12 @@ To set up the project locally:
npm run lint npm run lint
``` ```
5. **Git Hooks (Optional)**:
We provide a script to set up a git pre-commit hook that runs linting and CSS builds automatically before you commit.
```bash
./scripts/setup-pre-commit.sh
```
For a full guide, see the [Local Setup section in README.md](./README.md#local-setup). For a full guide, see the [Local Setup section in README.md](./README.md#local-setup).
## Dev Container ## Dev Container
+38
View File
@@ -0,0 +1,38 @@
#!/bin/bash
HOOK_FILE=".git/hooks/pre-commit"
if [ ! -d ".git" ]; then
echo "Error: .git directory not found. This script must be run from the repository root."
exit 1
fi
echo "Setting up pre-commit hook at $HOOK_FILE..."
cat > "$HOOK_FILE" << 'EOF'
#!/bin/sh
# pre-commit hook to run lint and build checks
echo "Running pre-commit checks..."
# Run lint
echo "Running lint..."
npm run lint
if [ $? -ne 0 ]; then
echo "Lint failed. Please fix errors before committing."
exit 1
fi
# Run CSS build to ensure consistency
echo "Running CSS build..."
npm run build:css
if [ $? -ne 0 ]; then
echo "CSS build failed. Please fix errors before committing."
exit 1
fi
echo "Pre-commit checks passed."
EOF
chmod +x "$HOOK_FILE"
echo "Pre-commit hook installed successfully."