Created
November 30, 2012 20:47
-
-
Save ilyakatz/4178477 to your computer and use it in GitHub Desktop.
Selective compilation
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
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