Skip to content

Instantly share code, notes, and snippets.

@fauxparse
Created January 27, 2009 11:35
Show Gist options
  • Save fauxparse/53305 to your computer and use it in GitHub Desktop.
Save fauxparse/53305 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Clean up the stale cached files from a theme
rake themes:uncache
# Restart the server: necessary to reload classes etc in production mode
touch tmp/restart.txt
namespace :themes do
desc "Clear out old cached versions of theme files"
task :uncache do
Dir[File.join(RAILS_ROOT, "themes/*")].each do |theme|
%w(images javascripts stylesheets).each do |dir|
if File.directory?(File.join(theme, dir))
Dir[File.join(theme, dir, "*")].each do |file|
dest = File.join RAILS_ROOT, "public", dir, File.basename(file)
if File.exist?(dest) && File.mtime(dest) < File.mtime(file)
puts "X #{dest}"
File.unlink(dest)
else
puts "- #{dest}"
end
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment