lib/spoom/cli/bump.rb in spoom-1.1.11 vs lib/spoom/cli/bump.rb in spoom-1.1.12
- old
+ new
@@ -1,10 +1,10 @@
# typed: true
# frozen_string_literal: true
-require 'find'
-require 'open3'
+require "find"
+require "open3"
module Spoom
module Cli
class Bump < Thor
extend T::Sig
@@ -83,11 +83,10 @@
exit(files_to_bump.empty?)
end
error_url_base = Spoom::Sorbet::Errors::DEFAULT_ERROR_URL_BASE
result = Sorbet.srb_tc(
- "--no-error-sections",
"--error-url-base=#{error_url_base}",
path: exec_path,
capture_err: true,
sorbet_bin: options[:sorbet]
)
@@ -106,21 +105,26 @@
exit(files_to_bump.empty?)
end
errors = Sorbet::Errors::Parser.parse_string(result.err, error_url_base: error_url_base)
- files_with_errors = errors.map do |err|
- path = File.expand_path(err.file)
+ all_files = errors.flat_map do |err|
+ [err.file, *err.files_from_error_sections]
+ end
+
+ files_with_errors = all_files.map do |file|
+ path = File.expand_path(file)
next unless path.start_with?(directory)
next unless File.file?(path)
next unless files_to_bump.include?(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]
+ 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?)
@@ -132,10 +136,10 @@
say("No file to bump from `#{from}` to `#{to}`")
return
end
message = StringIO.new
message << (dry ? "Can bump" : "Bumped")
- message << " `#{files.size}` file#{'s' if files.size > 1}"
+ message << " `#{files.size}` file#{"s" if files.size > 1}"
message << " from `#{from}` to `#{to}`:"
say(message.string)
files.each do |file|
file_path = Pathname.new(file).relative_path_from(path)
say(" + #{file_path}")