Skip to content

Commit 6bf27f3

Browse files
authored
Merge pull request #2395 from cub8/output-currently-compiling-gems
Print currently compiling gems. Add verbose attribute to gem command.
2 parents c082032 + 3864d7a commit 6bf27f3

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

lib/tapioca/cli.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ def gem(*gems)
301301
rbi_formatter: rbi_formatter(options),
302302
halt_upon_load_error: options[:halt_upon_load_error],
303303
lsp_addon: options[:lsp_addon],
304+
verbose: options[:verbose],
304305
}
305306

306307
command = if verify

lib/tapioca/commands/abstract_gem.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class AbstractGem < Command
88
include SorbetHelper
99
include RBIFilesHelper
1010

11-
#: (gem_names: Array[String], exclude: Array[String], include_dependencies: bool, prerequire: String?, postrequire: String, typed_overrides: Hash[String, String], outpath: Pathname, file_header: bool, include_doc: bool, include_loc: bool, include_exported_rbis: bool, ?number_of_workers: Integer?, ?auto_strictness: bool, ?dsl_dir: String, ?rbi_formatter: RBIFormatter, ?halt_upon_load_error: bool, ?lsp_addon: bool?) -> void
11+
#: (gem_names: Array[String], exclude: Array[String], include_dependencies: bool, prerequire: String?, postrequire: String, typed_overrides: Hash[String, String], outpath: Pathname, file_header: bool, include_doc: bool, include_loc: bool, include_exported_rbis: bool, ?number_of_workers: Integer?, ?auto_strictness: bool, ?dsl_dir: String, ?rbi_formatter: RBIFormatter, ?halt_upon_load_error: bool, ?lsp_addon: bool?, ?verbose: bool?) -> void
1212
def initialize(
1313
gem_names:,
1414
exclude:,
@@ -26,7 +26,8 @@ def initialize(
2626
dsl_dir: DEFAULT_DSL_DIR,
2727
rbi_formatter: DEFAULT_RBI_FORMATTER,
2828
halt_upon_load_error: true,
29-
lsp_addon: false
29+
lsp_addon: false,
30+
verbose: false
3031
)
3132
@gem_names = gem_names
3233
@exclude = exclude
@@ -41,6 +42,7 @@ def initialize(
4142
@dsl_dir = dsl_dir
4243
@rbi_formatter = rbi_formatter
4344
@lsp_addon = lsp_addon
45+
@verbose = verbose
4446

4547
super()
4648

@@ -58,6 +60,7 @@ def initialize(
5860
#: (Gemfile::GemSpec gem) -> void
5961
def compile_gem_rbi(gem)
6062
gem_name = set_color(gem.name, :yellow, :bold)
63+
say("Currently compiling #{gem_name}", :cyan) if @verbose
6164

6265
rbi = RBI::File.new(strictness: @typed_overrides[gem.name] || "true")
6366

spec/tapioca/cli/gem_spec.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,44 @@ module Reopened; end
381381
assert_success_status(result)
382382
end
383383

384+
it "must output currently compiling status with verbose flag" do
385+
foo = mock_gem("foo", "0.0.1") do
386+
write!("lib/foo.rb", FOO_RB)
387+
end
388+
389+
@project.require_mock_gem(foo)
390+
@project.bundle_install!
391+
392+
result = @project.tapioca("gem foo --verbose")
393+
394+
assert_stdout_includes(result, "Currently compiling foo")
395+
assert_stdout_includes(result, "Compiled foo")
396+
assert_stdout_includes(result, "create sorbet/rbi/gems/foo@0.0.1.rbi")
397+
398+
assert_project_file_equal("sorbet/rbi/gems/foo@0.0.1.rbi", FOO_RBI)
399+
assert_empty_stderr(result)
400+
assert_success_status(result)
401+
end
402+
403+
it "must output currently compiling with -V flag" do
404+
foo = mock_gem("foo", "0.0.1") do
405+
write!("lib/foo.rb", FOO_RB)
406+
end
407+
408+
@project.require_mock_gem(foo)
409+
@project.bundle_install!
410+
411+
result = @project.tapioca("gem foo -V")
412+
413+
assert_stdout_includes(result, "Currently compiling foo")
414+
assert_stdout_includes(result, "Compiled foo")
415+
assert_stdout_includes(result, "create sorbet/rbi/gems/foo@0.0.1.rbi")
416+
417+
assert_project_file_equal("sorbet/rbi/gems/foo@0.0.1.rbi", FOO_RBI)
418+
assert_empty_stderr(result)
419+
assert_success_status(result)
420+
end
421+
384422
it "must generate a gem RBI without the ones exported from the gem when called with `--no-exported-gem-rbis`" do
385423
foo = mock_gem("foo", "0.0.1") do
386424
write!("lib/foo.rb", FOO_RB)

0 commit comments

Comments
 (0)