Created
April 9, 2019 13:00
-
-
Save dcsg/dc9931b4fb52fa3eb6e92423733ea755 to your computer and use it in GitHub Desktop.
Git hooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# required to be able to input the response | |
exec < /dev/tty | |
# require to exit the docker container and kill the process | |
trap printout SIGINT | |
printout() { | |
exit | |
} | |
cmd_dry="$(pwd)/bin/php-cs-fixer fix --dry-run --diff"; | |
cmd_fix="$(pwd)/bin/php-cs-fixer fix --diff"; | |
while true; do | |
read -p "Run Linter? (Y/n) " -n 1 -t 4 yn | |
if [[ ${yn} = "" ]]; then | |
yn='Y'; | |
fi | |
case ${yn} in | |
[Yy]) | |
${cmd_dry}; | |
status=$?; | |
if [[ ${status} -eq 0 ]]; then | |
exit ${status}; | |
fi | |
${cmd_fix}; | |
exit ${status}; | |
;; | |
[Nn]) | |
exit 0; | |
;; | |
*) | |
echo "Please answer y or n for yes or no." | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment