983 B
983 B
Quickstart: Pre-Commit Gate
What This Feature Does
Adds a Git pre-commit hook (managed by Lefthook) that runs pnpm check before every commit. If any check fails, the commit is blocked.
Files to Create/Modify
| File | Action | Purpose |
|---|---|---|
lefthook.yml |
Create | Lefthook configuration with pre-commit hook |
package.json |
Modify | Add lefthook devDependency + prepare script |
Setup After Implementation
After the feature is implemented, hooks activate automatically:
pnpm install # installs lefthook + runs `prepare` which calls `lefthook install`
How It Works
- Developer runs
git commit - Lefthook intercepts via the Git pre-commit hook
- Lefthook runs
pnpm check(format + lint + typecheck + test) - If
pnpm checkexits 0 → commit proceeds - If
pnpm checkexits non-zero → commit is blocked, output shown
Bypass
git commit --no-verify # skips the pre-commit hook