Method: Consist::Commands::Upload#perform!

Defined in:
lib/consist/commands/upload.rb

#perform!(executor) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/consist/commands/upload.rb', line 12

def perform!(executor)
  # rubocop:disable Style/ClassEqualityComparison
  if @command[:local_file].class == Symbol
    puts "---> Uploading defined file #{@command[:local_file]}"
    target_file = Consist.files.detect { |f| f[:id] == @command[:local_file] }
    raise "\n\nNo declared file of ID `#{@command[:local_file]}`" unless target_file

    contents = StringIO.new(erb_template(target_file[:contents]))
    upload_defined_file(executor, contents, @command[:remote_path])
  else
    local_path = File.expand_path("../steps/#{@id}/#{@command[:local_file]}", __dir__)
    upload(executor, local_path, @command[:remote_path])
  end
  # rubocop:enable Style/ClassEqualityComparison
end