Files
Learn_System/scripts/install-hooks.sh
Maxim Dolgolyov 696049271f feat(dx): pre-commit hooks for local CI (no remote needed)
Local quality gate that runs on every git commit:
- node --check syntax on staged .js files
- block on new emoji in staged .js/.html/.css (md files allowed)
- block on new console.log/debug/debugger statements
- backend route auth lint (existing npm run lint:routes)
- backend tests (baseline 3 fails, block if grew)

Install: npm run hooks:install (top-level)
Bypass: git commit --no-verify

Skips slow checks when irrelevant files changed (tests/lint only run
if backend touched).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 21:49:58 +03:00

23 lines
615 B
Bash

#!/bin/sh
# install-hooks.sh — installs the LearnSpace pre-commit hook into .git/hooks/
# Usage: sh scripts/install-hooks.sh
# Or via npm: npm run hooks:install
set -e
REPO_ROOT="$(git rev-parse --show-toplevel)"
HOOKS_DIR="$REPO_ROOT/.git/hooks"
HOOK_FILE="$HOOKS_DIR/pre-commit"
cat > "$HOOK_FILE" << 'HOOK'
#!/bin/sh
# LearnSpace pre-commit hook (auto-generated — edit scripts/pre-commit.js)
REPO="$(git rev-parse --show-toplevel)"
node "$REPO/scripts/pre-commit.js" || exit 1
HOOK
chmod +x "$HOOK_FILE"
echo "Pre-commit hook installed at: $HOOK_FILE"
echo "Bypass anytime with: git commit --no-verify"