Git Hooks 생성기
pre-commit, pre-push 등 Git 훅 스크립트를 생성합니다.
훅 관리자
패키지 관리자
Git 훅 단계
Pre-Commit 검사 항목
pre-commit
# Block accidental commit of .env secrets
if git diff --cached --name-only | grep -qE "(^|/)\.env($|\.)" && ! git diff --cached --name-only | grep -qE "\.env\.example$"; then
echo "Error: Refusing to commit .env secret file. Unstage it first." >&2
exit 1
fi
npx --no -- lint-staged
npm run typecheck
설정 방법
npx --no -- husky init # Save script into .husky/pre-commit
함께 쓰는 설정 파일
{
"lint-staged": {
"*.{ts,tsx,js,jsx}": [
"eslint --fix",
"prettier --write"
],
"*.{json,md,css}": [
"prettier --write"
]
}
}