Skip to content

Instantly share code, notes, and snippets.

@dcsg
Created April 9, 2019 13:00
Show Gist options
  • Save dcsg/dc9931b4fb52fa3eb6e92423733ea755 to your computer and use it in GitHub Desktop.
Save dcsg/dc9931b4fb52fa3eb6e92423733ea755 to your computer and use it in GitHub Desktop.
Git hooks
#!/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