lib/spoom/cli/bump.rb in spoom-1.0.9 vs lib/spoom/cli/bump.rb in spoom-1.1.0

- old
+ new

@@ -24,10 +24,12 @@ desc: "Only display what would happen, do not actually change sigils" option :only, type: :string, default: nil, aliases: :o, desc: "Only change specified list (one file by line)" option :suggest_bump_command, type: :string, desc: "Command to suggest if files can be bumped" + option :count_errors, type: :boolean, default: false, + desc: "Count the number of errors if all files were bumped" sig { params(directory: String).void } def bump(directory = ".") in_sorbet_project! from = options[:from] @@ -46,10 +48,15 @@ unless Sorbet::Sigils.valid_strictness?(to) say_error("Invalid strictness `#{to}` for option `--to`") exit(1) end + if options[:count_errors] && !dry + say_error("`--count-errors` can only be used with `--dry`") + exit(1) + end + say("Checking files...") directory = File.expand_path(directory) files_to_bump = Sorbet::Sigils.files_with_sigil_strictness(directory, from) @@ -74,11 +81,16 @@ print_changes(files_to_bump, command: cmd, from: from, to: to, dry: dry, path: exec_path) undo_changes(files_to_bump, from) if dry exit(files_to_bump.empty?) end - output, no_errors = Sorbet.srb_tc(path: exec_path, capture_err: true, sorbet_bin: options[:sorbet]) + output, no_errors = Sorbet.srb_tc( + "--no-error-sections", + path: exec_path, + capture_err: true, + sorbet_bin: options[:sorbet] + ) if no_errors print_changes(files_to_bump, command: cmd, from: from, to: to, dry: dry, path: exec_path) undo_changes(files_to_bump, from) if dry exit(files_to_bump.empty?) @@ -92,9 +104,11 @@ next unless File.file?(path) path end.compact.uniq undo_changes(files_with_errors, from) + + say("Found #{errors.length} type checking error#{'s' if errors.length > 1}") if options[:count_errors] files_changed = files_to_bump - files_with_errors print_changes(files_changed, command: cmd, from: from, to: to, dry: dry, path: exec_path) undo_changes(files_to_bump, from) if dry exit(files_changed.empty?)