Skip to content

Commit

Permalink
Merge pull request #177 from tongueroo/rsync-detection
Browse files Browse the repository at this point in the history
rsync detection, stop on sh fail
  • Loading branch information
tongueroo authored Jan 29, 2019
2 parents 282dc35 + b179428 commit cc9eba0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/jets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

module Jets
RUBY_VERSION = "2.5.3"
class Error < StandardError; end

autoload :Application, "jets/application"
autoload :AwsInfo, "jets/aws_info"
Expand Down
14 changes: 14 additions & 0 deletions lib/jets/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,26 @@ def cp_r(src, dest)
# Using rsync to perform the copy.
src.chop! if src.ends_with?('/')
dest.chop! if dest.ends_with?('/')
check_rsync_installed!
sh "rsync -a --links --no-specials --no-devices #{src}/ #{dest}/", quiet: true
end

@@rsync_installed = false
def check_rsync_installed!
return if @@rsync_installed # only check once
if system "type rsync > /dev/null 2>&1"
@@rsync_installed = true
else
raise Jets::Error.new("Rsync is required. Rsync does not seem to be installed.")
end
end

def sh(command, quiet: false)
puts "=> #{command}" unless quiet
system(command)
success = $?.success?
raise Jets::Error.new("Command failed: #{command}") unless success
success
end
end
end

0 comments on commit cc9eba0

Please sign in to comment.