Skip to content

Instantly share code, notes, and snippets.

@ilyakatz
Created November 30, 2012 20:47
Show Gist options
  • Save ilyakatz/4178477 to your computer and use it in GitHub Desktop.
Save ilyakatz/4178477 to your computer and use it in GitHub Desktop.
Selective compilation
last_revision = run "cat #{current_path}/REVISION"
assets_modified = run "git diff --name-only #{last_revision} | grep '/assets/' | wc -l"
if assets_modified.output.to_i > 0
info "#{assets_modified} asset files changed detected. Compiling assets"
`cd #{release_path} && PATH=#{release_path}/ey_bundler_binstubs:$PATH #{environment} rake assets:precompile RAILS_GROUPS=assets"`
else
info "No asset changes detected. Copying assets from previous"
current = shared_path + '/assets'
last_asset_path = shared_path + '/last_assets'
run <<-COMMAND
if [ -d #{current_path} ]; then
rm -rf #{last_asset_path} && mkdir #{last_asset_path} && mv #{current} #{last_asset_path} && mkdir -p #{current};
else
mkdir -p #{current} #{last_asset_path};
fi;
ln -nfs #{current} #{last_asset_path} #{current_path + '/public'}
COMMAND
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment