Skip to content

Commit d50b3d4

Browse files
committed
Resolve #147: Add commit hook for pre-commit code fix
1 parent eab06ef commit d50b3d4

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ composer.lock
88
tests/caches/
99
!tests/caches/.gitkeep
1010
tools
11+
cghooks.lock

composer.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"require-dev": {
3535
"phpunit/phpunit": "^8.0",
3636
"squizlabs/php_codesniffer": "^3.4",
37-
"friendsofphp/php-cs-fixer": "^2.14"
37+
"friendsofphp/php-cs-fixer": "^2.14",
38+
"brainmaestro/composer-git-hooks": "^2.6"
3839
},
3940
"scripts": {
4041
"test": "phpunit tests --stop-on-failure",
@@ -44,6 +45,13 @@
4445
"@test",
4546
"@cs",
4647
"@fix"
47-
]
48+
],
49+
"post-install-cmd": "cghooks add --ignore-lock",
50+
"post-update-cmd": "cghooks update"
51+
},
52+
"extra": {
53+
"hooks": {
54+
"pre-commit": "git diff-index --cached --name-only HEAD | xargs -n1 vendor/bin/php-cs-fixer fix"
55+
}
4856
}
4957
}

0 commit comments

Comments
 (0)