Skip to content

Instantly share code, notes, and snippets.

@app2641
Created February 21, 2017 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save app2641/25717922d4f038b1e8a5a772c6a88d9b to your computer and use it in GitHub Desktop.
Save app2641/25717922d4f038b1e8a5a772c6a88d9b to your computer and use it in GitHub Desktop.
.git/hooks/pre-commit
#! /bin/sh
git df --cached --name-only --diff-filter=AM | grep '\.rb$' | grep -v 'db/schema.rb' | xargs bundle exec rubocop -c .rubocop.yml
RUBOCOP=$?
git df --cached --name-only --diff-filter=AM | grep '\.js$' | xargs npm run lint
ESLINT=$?
if [ $RUBOCOP -eq $ESLINT ]; then
exit 0
else
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment