Created
February 9, 2012 10:23
-
-
Save lukaszx0/1779098 to your computer and use it in GitHub Desktop.
Assets pre-commit precompile
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 | |
assets = `git diff --cached --name-only`.split("\n").find_all{ |file| file =~ /\.(css|js)$/ } | |
unless assets.empty? | |
puts "You've changed some of asset files. Building..." | |
files = `bundle exec rake asset:packager:build_all`.split("\n")[1..-1].map{ |f| f.gsub(/^Created (\/.*\.(css|js))$/, "\\1") } | |
`git add #{files.join(" ")}` | |
end | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment