Created
June 14, 2016 14:33
-
-
Save tarto-dev/0273e101b191bbde25fcb62de08c340d to your computer and use it in GitHub Desktop.
This file contains 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 | |
CUR_USER=$(whoami) | |
#DRUSH_EXEC="/usr/bin/php /Users/$CUR_USER/.composer/vendor/bin/drush" | |
DRUSH_EXEC="/Applications/MAMP/bin/php/php5.5.18/bin/php /etc/apps/drush/drush.php" | |
#PHPCS_EXEC="/Users/$CUR_USER/.composer/vendor/bin/phpcs" | |
PHPCS_EXEC="/Applications/MAMP/bin/php/php5.5.18/bin/phpcs" | |
if which composer >/dev/null; then | |
echo "Composer were found" | |
if which phpcs >/dev/null; then | |
echo "phpcs found" | |
else | |
composer global require "squizlabs/php_codesniffer=*" | |
fi | |
else | |
echo "Composer is required to install and use this pre-commit hook !" | |
exit 1; | |
fi | |
if [[ -e "/Users/$CUR_USER/.drupal/coder/coder_sniffer/Drupal" ]]; then | |
echo "Coder files found" | |
else | |
mkdir -p /Users/$CUR_USER/.drupal | |
#drush dl coder-7.x-2.5 --destination=/Users/$CUR_USER/.drupal/ | |
$DRUSH_EXEC dl coder-7.x-2.5 --destination=/Users/$CUR_USER/.drupal/ | |
fi | |
git diff --cached --name-only | while read FILE; do | |
if [[ "$FILE" =~ ^.+(php|inc|module|install|test)$ ]]; then | |
RESULT=$(grep "dpm(\|krumo(\|var_dump(" "$FILE") | |
if [ ! -z $RESULT ]; then | |
echo -e "Warning, the commit contains a call to dpm/krumo/var_dump. Commit was not aborted, however." >&2 | |
sleep 2 | |
fi | |
$PHPCS_EXEC --standard=/Users/$CUR_USER/.drupal/coder/coder_sniffer/Drupal "$FILE" 1> /dev/null | |
if [ $? -ne 0 ]; then | |
echo "Warning, some files do not respecting the Drupal coding standards. Commit was not aborted, however." >&2 | |
sleep 2 | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment