Created
January 10, 2013 16:53
-
-
Save csexton/4503716 to your computer and use it in GitHub Desktop.
Capistrano Recipe to skip asset compilation if nothing has changed
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 :deploy do | |
namespace :assets do | |
def should_update_assets | |
from = source.next_revision(current_revision) | |
capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ app/assets/ | wc -l").to_i > 0 | |
rescue | |
true | |
end | |
task :precompile, :roles => :web, :except => { :no_release => true } do | |
if should_update_assets | |
run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile} | |
else | |
logger.info "Skipping asset pre-compilation because there were no asset changes" | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment