diff --git a/lib/capistrano/recipes/deploy/strategy/rsync_with_remote_cache.rb b/lib/capistrano/recipes/deploy/strategy/rsync_with_remote_cache.rb index 7c4caff..b7c2785 100644 --- a/lib/capistrano/recipes/deploy/strategy/rsync_with_remote_cache.rb +++ b/lib/capistrano/recipes/deploy/strategy/rsync_with_remote_cache.rb @@ -25,10 +25,40 @@ def self.default_attribute(attribute, default_value) def deploy! update_local_cache + build update_remote_cache copy_remote_cache end + def execute description, &block + logger.debug description + handle_system_errors &block + end + + def handle_system_errors &block + block.call + raise_command_failed if last_command_failed? + end + + def raise_command_failed + raise Capistrano::Error, "shell command failed with return code #{$?}" + end + + def last_command_failed? + $? != 0 + end + + def build_script + configuration[:build_script] + end + + def build + return unless build_script + execute "running build script on #{local_cache_path}" do + Dir.chdir(local_cache_path) { system(build_script) } + end + end + def update_local_cache system(command) mark_local_cache