lib/spoom/cli/bump.rb in spoom-1.1.13 vs lib/spoom/cli/bump.rb in spoom-1.1.14

- old
+ new

@@ -26,10 +26,11 @@ 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" + option :sorbet_options, type: :string, default: "", desc: "Pass options to Sorbet" sig { params(directory: String).void } def bump(directory = ".") in_sorbet_project! from = options[:from] @@ -83,10 +84,11 @@ exit(files_to_bump.empty?) end error_url_base = Spoom::Sorbet::Errors::DEFAULT_ERROR_URL_BASE result = Sorbet.srb_tc( + *options[:sorbet_options].split(" "), "--error-url-base=#{error_url_base}", path: exec_path, capture_err: true, sorbet_bin: options[:sorbet], ) @@ -101,9 +103,17 @@ if result.status 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 + + unless result.exit_code == 100 + # Sorbet will return exit code 100 if there are type checking errors. + # If Sorbet returned something else, it means it didn't terminate normally. + say_error(result.err, status: nil, nl: false) + undo_changes(files_to_bump, from) + exit(1) end errors = Sorbet::Errors::Parser.parse_string(result.err, error_url_base: error_url_base) all_files = errors.flat_map do |err|