From f815294a1fdf77b9d60bf0e53d252b6ed3c227ed Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Thu, 25 Nov 2021 12:10:47 +0100 Subject: [PATCH] Allow hooks to run all checks before terminating Signed-off-by: Christian Wolf --- .hooks/pre-commit | 12 ++++++++++-- .hooks/pre-push | 12 ++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.hooks/pre-commit b/.hooks/pre-commit index 703e05ae..7e9d8ec3 100755 --- a/.hooks/pre-commit +++ b/.hooks/pre-commit @@ -14,6 +14,14 @@ cleanup() { trap cleanup EXIT -if [ -e 'node_modules/.bin/eslint' ]; then - npm run --silent eslint || { echo 'The javascript code seems to be not satifying the eslint linter.'; exit 1; } +retVal=0 + +if [ -e 'vendor/bin/php-cs-fixer' ]; then + composer cs:check || { echo "The PHP code is not validly formatted."; (( retVal |= 1 )); } fi + +if [ -e 'node_modules/.bin/eslint' ]; then + npm run --silent eslint || { echo 'The javascript code seems to be not satifying the eslint linter.'; (( retVal |= 2 )); } +fi + +exit $retVal diff --git a/.hooks/pre-push b/.hooks/pre-push index 7707579b..6ec972eb 100755 --- a/.hooks/pre-push +++ b/.hooks/pre-push @@ -14,20 +14,24 @@ cleanup() { trap cleanup EXIT +retVal=0 + if [ -e 'vendor/bin/php-cs-fixer' ]; then - composer cs:check || { echo "The PHP code is not validly formatted."; exit 1; } + composer cs:check || { echo "The PHP code is not validly formatted."; (( retVal |= 1 )); } fi if [ -e 'node_modules/.bin/eslint' ]; then - npm run eslint || { echo 'The javascript code seems to be not satifying the eslint linter.'; exit 2; } + npm run eslint || { echo 'The javascript code seems to be not satifying the eslint linter.'; (( retVal |= 2 )); } fi if [ -e 'node_modules/.bin/prettier' ]; then - npm run prettier || { echo 'The javascript code seems to be not satifying the prettier code styler.'; exit 3; } + npm run prettier || { echo 'The javascript code seems to be not satifying the prettier code styler.'; (( retVal |= 4 )); } fi if [ -e 'node_modules/.bin/stylelint' ]; then - npm run stylelint || { echo 'The CSS code seems to be not satifying the stylelint linter.'; exit 4; } + npm run stylelint || { echo 'The CSS code seems to be not satifying the stylelint linter.'; (( retVal |= 8 )); } fi + +exit $retVal