Class: CodeFormatter::SwiftFormatFormatter

Inherits:
Formatter
  • Object
show all
Defined in:
lib/code_formatter/formatters/swift_format_formatter.rb

Instance Attribute Summary

Attributes inherited from Formatter

#config, #path

Instance Method Summary collapse

Methods inherited from Formatter

#initialize

Constructor Details

This class inherits a constructor from CodeFormatter::Formatter

Instance Method Details

#formatObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/code_formatter/formatters/swift_format_formatter.rb', line 6

def format
  unless Environment.exist? 'git'
    warn 'warning: failed to find git command'
    return
  end

  unless Environment.exist? 'swiftformat'
    warn "warning: [swiftformat] not found (to install it run 'brew install swiftformat')"
    return
  end

  files = files_to_format
  if files.empty?
    puts '[swiftformat]: everything is up-to-date'
  else
    puts "[swiftformat]: going to format files:\n#{files.join('\n')}"
    format_files(files)
  end
end