Skip to content

Instantly share code, notes, and snippets.

@lukaszx0
Created February 9, 2012 10:23
Show Gist options
  • Save lukaszx0/1779098 to your computer and use it in GitHub Desktop.
Save lukaszx0/1779098 to your computer and use it in GitHub Desktop.
Assets pre-commit precompile
#!/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