Created
September 14, 2012 00:34
-
-
Save edmundsalvacion/3718985 to your computer and use it in GitHub Desktop.
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
%w(app as).each do |role| | |
desc "Adds #{role} to the target roles for the task" | |
task(role) do | |
if ENV['ROLES'] | |
ENV['ROLES'] += ",#{role}" | |
else | |
ENV['ROLES'] = role | |
end | |
end | |
end | |
desc "Executes the task as sudo" | |
task :use_sudo do | |
ENV['SUDO'] = '1' | |
end | |
namespace :assets do | |
namespace :assets do | |
desc <<-DESC | |
Run the asset precompilation rake task. You can specify the full path \ | |
to the rake executable by setting the rake variable. You can also \ | |
specify additional environment variables to pass to rake via the \ | |
asset_env variable. The defaults are: | |
set :rake, "rake" | |
set :rails_env, "production" | |
set :asset_env, "RAILS_GROUPS=assets" | |
DESC | |
task :precompile, roles: assets_role, except: { no_release: true } do | |
from = source.next_revision(current_revision) | |
cmd = "cd #{latest_release} && #{source.local.log(from)} vendor/assets/ app/assets/ | wc -l" | |
assets_changed = capture(cmd).to_i > 0 | |
if releases.length <= 1 || assets_changed | |
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