Skip to content

Instantly share code, notes, and snippets.

@jwage
Last active February 6, 2018 16:49
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jwage/c4ef1dcb95007b5be0da to your computer and use it in GitHub Desktop.
Save jwage/c4ef1dcb95007b5be0da to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
ROOT="/data/devo/current"
echo "OpenSky pre commit hook start"
PHP_CS_FIXER="vendor/bin/php-cs-fixer"
HAS_PHP_CS_FIXER=false
HAS_JSHINT=false
if [ -x vendor/bin/php-cs-fixer ]; then
HAS_PHP_CS_FIXER=true
fi
if [ -x node_modules/gulp-jshint ]; then
HAS_JSHINT=true
fi
if $HAS_PHP_CS_FIXER; then
git status --porcelain | grep -e '^[AM]\(.*\).php$' | cut -c 3- | while read line; do
$PHP_CS_FIXER fix --config-file=$ROOT/.php_cs --verbose "$line";
git add "$line";
done
else
echo ""
echo "Please install php-cs-fixer, e.g.:"
echo ""
echo " composer require --dev fabpot/php-cs-fixer:dev-master"
echo ""
fi
if $HAS_JSHINT; then
git status --porcelain | grep -e '^\s*[AM]\(.*\).js$' | cut -c 3- | while read line; do gulp jshint --filter=${line}; done;
else
echo ""
echo "Please run 'npm install' to run 'gulp jshint'."
echo ""
fi
echo "OpenSky pre commit hook finish"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment