Created
October 8, 2014 07:14
-
-
Save tobiashm/21edd17d0b96795dcdf9 to your computer and use it in GitHub Desktop.
Run RuboCop and NPM check on `git commit`
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 | |
| [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" | |
| if [ -f ".rubocop.yml" ]; then | |
| changed_ruby_files=$(git diff --cached --name-only --diff-filter=ACM | grep -e '\.rb$' | grep -v 'db/schema') | |
| if [ "$changed_ruby_files" != "" ]; then | |
| cd . # Cause RVM to change Ruby version to the one specified in the Gemfile or .ruby-version | |
| bundle exec rubocop -n $changed_ruby_files || exit 1 | |
| fi | |
| fi | |
| PATH=/usr/local/bin:$PATH | |
| if [ -f "package.json" ]; then | |
| npm install 1>&2 | |
| npm run check || exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment