lib/scan/report_collector.rb in scan-0.7.1 vs lib/scan/report_collector.rb in scan-0.8.0

- old
+ new

@@ -1,14 +1,15 @@ module Scan class ReportCollector SUPPORTED = %w(html junit json-compilation-database) # Intialize with values from Scan.config matching these param names - def initialize(open_report, output_types, output_directory) + def initialize(open_report, output_types, output_directory, use_clang_report_name) @open_report = open_report @output_types = output_types @output_directory = output_directory + @use_clang_report_name = use_clang_report_name end def parse_raw_file(path) UI.user_error!("Couldn't find file at path '#{path}'") unless File.exist?(path) @@ -22,11 +23,11 @@ `open --hide '#{output_path}'` end end end - # Returns a hash containg the resulting path as key and the command as value + # Returns a hash containing the resulting path as key and the command as value def generate_commands(path, types: nil, output_file_name: nil) types ||= @output_types types = types.split(",") if types.kind_of?(String) # might already be an array when passed via fastlane commands = {} @@ -36,20 +37,28 @@ unless SUPPORTED.include?(type) UI.error("Couldn't find reporter '#{type}', available #{SUPPORTED.join(', ')}") next end - file_name = "report.#{type}" - output_path = output_file_name || File.join(File.expand_path(@output_directory), file_name) + output_path = output_file_name || File.join(File.expand_path(@output_directory), determine_output_file_name(type)) + parts = ["cat '#{path}' | "] parts << "xcpretty" parts << "--report #{type}" parts << "--output '#{output_path}'" parts << "&> /dev/null " commands[output_path] = parts.join(" ") end return commands + end + + def determine_output_file_name(type) + if @use_clang_report_name && type == "json-compilation-database" + "compile_commands.json" + else + "report.#{type}" + end end end end