Class: Spoom::Cli::Bump
- Inherits:
-
Thor
- Object
- Thor
- Spoom::Cli::Bump
- Extended by:
- T::Sig
- Includes:
- Helper
- Defined in:
- lib/spoom/cli/bump.rb
Instance Method Summary collapse
Methods included from Helper
#color?, #colorize, #exec_path, #in_sorbet_project!, #in_sorbet_project?, #say_error, #sorbet_config
Instance Method Details
#bump(directory = ".") ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/spoom/cli/bump.rb', line 20 def bump(directory = ".") in_sorbet_project! from = [:from] to = [:to] force = [:force] unless Sorbet::Sigils.valid_strictness?(from) say_error("Invalid strictness #{from} for option --from") exit(1) end unless Sorbet::Sigils.valid_strictness?(to) say_error("Invalid strictness #{to} for option --to") exit(1) end directory = File.(directory) files_to_bump = Sorbet::Sigils.files_with_sigil_strictness(directory, from) Sorbet::Sigils.change_sigil_in_files(files_to_bump, to) return if force output, no_errors = Sorbet.srb_tc(path: exec_path, capture_err: true) return if no_errors errors = Sorbet::Errors::Parser.parse_string(output) files_with_errors = errors.map do |err| path = File.(err.file) next unless path.start_with?(directory) next unless File.file?(path) path end.compact.uniq Sorbet::Sigils.change_sigil_in_files(files_with_errors, from) end |