Felipe97/llama-cpp-compiled
01.2k
1#!/usr/bin/env bash2#3# Pre-commit hook for llama-ui4# Runs: format (staged files only) + type-check5# Stashes unstaged changes temporarily and restores them after.6 7# Only run when there are staged changes in tools/ui/8if ! git diff --cached --name-only | grep -q "^tools/ui/"; then9 exit 010fi11 12REPO_ROOT=$(git rev-parse --show-toplevel)13cd "$REPO_ROOT/tools/ui"14 15# Check that node_modules exists16if [ ! -d "node_modules" ]; then17 echo "❌ node_modules not found. Run 'npm ci' first."18 exit 119fi20 21# Stash unstaged changes in tools/ui/ so they don't interfere22stash_name="pi-ui-precommit"23git stash push --keep-index -u -m "$stash_name" -- tools/ui/ 2>/dev/null || true24 25echo "Running pre-commit checks for llama-ui..."26 27# Format only staged files28staged_ui=$(git diff --cached --name-only -- tools/ui/)29if [ -n "$staged_ui" ]; then30 echo "$staged_ui" | xargs npm run format31 format_ok=$?32 # Re-stage formatted files33 git add tools/ui/34else35 format_ok=036fi37 38# Type-check the clean tree39npm run check40check_ok=$?41 42# Restore stashed changes43if git stash list | grep -q "$stash_name"; then44 git stash pop 2>/dev/null || true45fi46 47if [ $format_ok -ne 0 ]; then48 echo "❌ Format failed"49 exit 150fi51if [ $check_ok -ne 0 ]; then52 echo "❌ Type check failed"53 exit 154fi55 56echo "✅ Pre-commit checks passed"57exit 058 