Skip to content

Instantly share code, notes, and snippets.

@ecin
Created December 6, 2010 22:05
Show Gist options
  • Save ecin/731067 to your computer and use it in GitHub Desktop.
Save ecin/731067 to your computer and use it in GitHub Desktop.
Bundle assets when they change.
#!/usr/bin/env ruby
require 'yaml'
top_dir = `git rev-parse --show-toplevel`.chomp
changes = `git diff --cached --name-only`.chomp.split
assets = YAML.load_file "#{top_dir}/config/assets.yml"
assets = assets['javascripts'].values + assets['stylesheets'].values
assets.flatten!
unless (assets & changes).empty?
p "Compressing assets with jammit... "
`bundle exec jammit --force`
puts "done!"
`git add #{top_dir}/public/assets`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment