Created
November 12, 2011 14:49
-
-
Save aalin/1360618 to your computer and use it in GitHub Desktop.
pre-commit hook that checks syntax of changed files.
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
| #!/usr/bin/env ruby | |
| `git diff --cached --name-only --diff-filter=AM`.lines.each do |filename| | |
| path = File.join(Dir.pwd, filename.strip) | |
| puts "Checking syntax of #{ filename.strip }" | |
| case filename | |
| when /.haml$/ | |
| exit 1 unless system('haml', '--check', path) | |
| when /.scss$/ | |
| exit 1 unless system('scss', '--check', path) | |
| when /.rb$/ | |
| exit 1 unless system('ruby', '-c', path) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment