class Middleman::Cli::Rsync

Public Class Methods

exit_on_failure?() click to toggle source

Tell Thor to exit with a non-zero exit code on failure

# File lib/middleman-rsync/commands.rb, line 19
def self.exit_on_failure?
  true
end

Public Instance Methods

rsync() click to toggle source
# File lib/middleman-rsync/commands.rb, line 23
def rsync
  unless environment == "staging" || environment == "production"
    raise Thor::Error, "Unknown environment '#{environment}'. Use 'staging' or 'production'."
  end

  app = ::Middleman::Application.new
  config = app.extensions[:rsync].options
  server = config["#{environment}_server".to_sym]

  if options[:build]
    puts "Building locally..."
    run("middleman build") || exit(1)
  end

  puts "\nReady for deployment to #{environment}: #{server}\n\n"

  if not ["yes", "y"].include?(ask("OK? [Yes|y|Y|No|n|N] > ").downcase)
    puts "\nExiting."
    exit(1)
  else
    puts
  end

  puts "Running rsync..."
  run("rsync #{config[:rsync_flags]} ./build/ #{config[:user]}@#{server}:#{config[:path]}")

  puts "Complete."
end