Sha256: b05dcc326b13df9d9874937b5c3a1686e1789b4abf6b78b308422983667c594a
Contents?: true
Size: 1.92 KB
Versions: 1
Compression:
Stored size: 1.92 KB
Contents
# Original source: https://coderwall.com/p/aridag # set the locations that we will look for changed assets to determine whether to precompile set :assets_dependencies, %w(app/assets lib/assets vendor/assets Gemfile.lock config/routes.rb) # clear the previous precompile task Rake::Task["deploy:assets:precompile"].clear_actions class PrecompileRequired < StandardError; end namespace :deploy do namespace :assets do desc "Precompile assets" task :precompile do on roles(fetch(:assets_roles)) do within release_path do with rails_env: fetch(:rails_env) do begin # find the most recent release latest_release = capture(:ls, '-xr', releases_path).split[1] # precompile if this is the first deploy raise PrecompileRequired unless latest_release latest_release_path = releases_path.join(latest_release) # precompile if the previous deploy failed to finish precompiling execute(:ls, latest_release_path.join('assets_manifest_backup')) rescue raise(PrecompileRequired) fetch(:assets_dependencies).each do |dep| release = release_path.join(dep) latest = latest_release_path.join(dep) # skip if both directories/files do not exist next if [release, latest].map{|d| test "[ -e #{d} ]"}.uniq == [false] # execute raises if there is a diff execute(:diff, '-Nqr', release, latest) rescue raise(PrecompileRequired) end info("Skipping asset precompile, no asset diff found") # copy over all of the assets from the last release execute(:cp, '-r', latest_release_path.join('public', fetch(:assets_prefix)), release_path.join('public', fetch(:assets_prefix))) rescue PrecompileRequired execute(:rake, "assets:precompile") end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
capistrano-faster-assets-1.0.2 | lib/capistrano/tasks/faster_assets.rake |