Last active
August 29, 2015 13:57
-
-
Save dtaniwaki/9542915 to your computer and use it in GitHub Desktop.
Skip assets:precompile only if the assets are updated.
This file contains hidden or 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
| def do_if_updated(tag, *sources, &block) | |
| to = (latest_revision rescue nil) | |
| from = (current_revision rescue nil) | |
| doit = if !from || !to || !fetch(:smart_assets_precompile, true) | |
| true | |
| else | |
| run_locally("#{source.local.log(from, to)} #{sources.join(' ')} | wc -l").to_i > 0 | |
| end | |
| if doit | |
| block.call | |
| else | |
| logger.important "Skipping [#{tag}] because there was no change in #{sources.join(' ')} between #{from} and #{to}" | |
| end | |
| end | |
| namespace :assets do | |
| task :precompile, roles: :app do | |
| do_if_updated("assets precompile", "vendor/assets/", "app/assets/", "lib/assets/", "config") do | |
| run %Q{cd #{current_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile} | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment