A collection of modules for which every is designed to check syntax in files to be commited via git.
Checker is available in rubygems, so you just need to do:
gem install checker
If you are using bundler, you can add it to your project via Gemfile
file (best to put it under :development
group):
group :development do
gem 'checker'
end
After installing the gem please follow Git hook section for further details.
If you want every commit be appended with checker approved icon (:checkered_flag:) add to your .git/hooks/prepare-commit-msg
following:
#!/bin/bash
checker
if [ $? == 1 ]; then
exit 1
fi
echo ":checkered_flag:" >> $1
To just check your source code every time you commit, add to your .git/hooks/pre-commit
line:
#!/bin/bash
checker
Use only either one hook.
Don't forget to make the hooks files executable:
chmod +x .git/hooks/pre-commit
chmod +x .git/hooks/prepare-commit-msg
Now checker will halt the commit if it finds problem with source code:
Checking app/models/user.rb...
FAIL app/models/user.rb found occurence of 'binding.pry'
46:binding.pry
To check only specific filetypes on commit, use git config
:
git config checker.check 'ruby, haml, coffeescript'
Available options are: ruby, haml, pry, coffeescript, sass
For various modules to work you may need to install additional dependencies:
- coffeescript -
npm install -g coffee-script
- see https://github.com/jashkenas/coffee-script/ - javascript - install jsl binary - see http://www.javascriptlint.com/download.htm
- haml & sass -
gem install haml
gem install sass