Class: Middleman::Cli::S3Sync

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/middleman-s3_sync/commands.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/middleman-s3_sync/commands.rb', line 14

def self.exit_on_failure?
  true
end

Instance Method Details

#s3_syncObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/middleman-s3_sync/commands.rb', line 35

def s3_sync
  ::Middleman::S3Sync.app = ::Middleman::Application.server.inst do
    config[:environment] = :build
  end

  s3_sync_options = ::Middleman::S3Sync.s3_sync_options

  bucket = s3_sync_options.bucket rescue nil

  unless bucket
    raise Thor::Error.new "You need to activate the s3_sync extension and at least provide the bucket name."
  end


  # Override options based on what was passed on the command line...
  s3_sync_options.force = options[:force] if options[:force]
  s3_sync_options.bucket = options[:bucket] if options[:bucket]
  s3_sync_options.verbose = options[:verbose] if options[:verbose]
  if options[:prefix]
    s3_sync_options.prefix  = options[:prefix] if options[:prefix]
    s3_sync_options.prefix = s3_sync_options.prefix.end_with?("/") ? s3_sync_options.prefix : s3_sync_options.prefix + "/"
  end
  s3_sync_options.dry_run = options[:dry_run] if options[:dry_run]

  ::Middleman::S3Sync.sync()
end