-
-
Save khansensf/1714387 to your computer and use it in GitHub Desktop.
simple Rake task for cleanup of Rails directory
This file contains 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
namespace :admin do | |
desc "Clean up all temporary files in the application directory" | |
task :cleanup, :needs => :environment do | |
puts "Removing temporary directory contents" | |
tmp_files = [] | |
%w{ cache pids sessions sockets }.each do |dir| | |
tmp_files += Dir.glob( File.join(Rails.root, "tmp", dir, "*") ) | |
end | |
File.delete(*tmp_files) | |
puts "Removing log files" | |
log_files = Dir.glob( File.join(Rails.root, "log", "*") ) | |
File.delete(*log_files) | |
puts "Removing emacs temporary files" | |
emacs_tmp_files = Dir.glob( File.join(Rails.root, "**", "*~") ) | |
emacs_tmp_files += Dir.glob( File.join(Rails.root, "**", "\#*\#") ) | |
File.delete(*emacs_tmp_files) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
May want to add a line to remove those annoying lock files (.#filename)
emacs_tmp_files += Dir.glob( File.join(Rails.root, "*", "#") )