Skip to content

Instantly share code, notes, and snippets.

@tizoc
Created June 16, 2011 21:11
Show Gist options
  • Save tizoc/1030286 to your computer and use it in GitHub Desktop.
Save tizoc/1030286 to your computer and use it in GitHub Desktop.
task :watch_assets => [:compile_css, :compile_js] do |t, args|
timeout = ENV['WATCH_ASSETS_TIMEOUT'] || '0.2'
lockdir = './assets.lock'
cmd = <<-EOS
if mkdir #{lockdir} &>/dev/null; then
sleep #{timeout}
rake -s compile_css
rake -s compile_js
rmdir #{lockdir}
fi
EOS
system(%Q{watchmedo shell-command --patterns="*.js;*.scss" --command='#{cmd}' app/views/css/ public/js})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment