Skip to content

Commit 341ea29

Browse files
committed
Added pre commit scripts
1 parent 5e42da0 commit 341ea29

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

scripts/.pre-commit-setup.bat

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
@echo off
2+
REM Pre-commit hooks setup script for jsweb (Windows)
3+
REM This script sets up pre-commit hooks to automatically run code quality checks
4+
5+
setlocal enabledelayedexpansion
6+
7+
echo 🔧 Setting up pre-commit hooks for jsweb...
8+
9+
REM Check if pre-commit is installed
10+
where pre-commit >nul 2>nul
11+
if errorlevel 1 (
12+
echo 📦 Installing pre-commit...
13+
pip install pre-commit
14+
)
15+
16+
REM Install the git hooks
17+
echo 📝 Installing git pre-commit hooks...
18+
pre-commit install
19+
pre-commit install --hook-type pre-push
20+
21+
REM Optional: Run all hooks on all files to check current state
22+
echo 🔍 Running hooks on all files (this may take a moment)...
23+
pre-commit run --all-files || exit /b 0
24+
25+
echo ✅ Pre-commit hooks setup complete!
26+
echo.
27+
echo 📚 Usage:
28+
echo - Hooks will run automatically before each commit
29+
echo - Run manually: pre-commit run --all-files
30+
echo - Skip hooks: git commit --no-verify
31+
echo - Update hooks: pre-commit autoupdate
32+
echo.
33+
34+
pause

scripts/.pre-commit-setup.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
# Pre-commit hooks setup script for jsweb
3+
# This script sets up pre-commit hooks to automatically run code quality checks
4+
5+
set -e
6+
7+
echo "🔧 Setting up pre-commit hooks for jsweb..."
8+
9+
# Check if pre-commit is installed
10+
if ! command -v pre-commit &> /dev/null; then
11+
echo "📦 Installing pre-commit..."
12+
pip install pre-commit
13+
fi
14+
15+
# Install the git hooks
16+
echo "📝 Installing git pre-commit hooks..."
17+
pre-commit install
18+
pre-commit install --hook-type pre-push
19+
20+
# Optional: Run all hooks on all files to check current state
21+
echo "🔍 Running hooks on all files (this may take a moment)..."
22+
pre-commit run --all-files || true
23+
24+
echo "✅ Pre-commit hooks setup complete!"
25+
echo ""
26+
echo "📚 Usage:"
27+
echo " - Hooks will run automatically before each commit"
28+
echo " - Run manually: pre-commit run --all-files"
29+
echo " - Skip hooks: git commit --no-verify"
30+
echo " - Update hooks: pre-commit autoupdate"
31+
echo ""

0 commit comments

Comments
 (0)