npm install
명령어를 입력해 husky와 lint-staged 모듈을 다운받습니다.
자신이 작업할 폴더(backend 또는 frontend)로 이동해 npm run prepare
를 실행합니다.
git commit
시 실행할 git hook script 파일의 위치를 설정하는 것으로 언제든 npm run prepare
를 통해 변경할 수 있습니다.이제 git commit
시 pre-commit
git hook script가 자동으로 실행되며 다음과 같은 작업을 합니다.
branch 이름이 프로젝트의 naming convention을 따르는지 검사
commit message 작성 전에 lint-staged로 linter와 formatter 적용
pre-commit
git hook script에서는 branch 이름이 backend로 시작하면 backend에서 작업한 것으로 간주하며, git commit
실행 시 frontend의 script가 실행될 경우 다음과 같은 경고 메시지가 출력됩니다. 그 반대도 마찬가지이며 필요한 경우 경고 메시지의 안내에 따릅니다.
git commit
시 git hook의 실행을 skip하고 싶다면 n/--no-verify
option을 사용합니다. Root directory에서 작업한 경우와 같이 특수한 경우가 아니라면 git hook의 실행을 skip하는 행동은 지양합니다.
git commit -n # Skips git hooks