Method: LonoCfn::Base#detect_format

Defined in:
lib/lono_cfn/base.rb

#detect_formatObject

Returns String with value of “yml” or “json”.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/lono_cfn/base.rb', line 98

def detect_format
  formats = Dir.glob("#{@project_root}/output/**/*").map { |path| path }.
              reject { |s| s =~ %r{/params/} }. # reject output/params folder
              map { |path| File.extname(path) }.
              reject { |s| s.empty? }. # reject ""
              uniq
  if formats.size > 1
    puts "ERROR: Detected multiple formats: #{formats.join(", ")}".colorize(:red)
    puts "All the output files must use the same format.  Either all json or all yml."
    exit 1
  else
    formats.first.sub(/^\./,'')
  end
end