Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/tapioca/commands/abstract_dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ def generate_dsl_rbi_files(outpath, quiet:)
)
end.compact

if @only.any?
say("Skipping stale RBI removal because `--only` is set.", :yellow)
return Set.new
end

files_to_purge = existing_rbi_files - generated_files

files_to_purge
Expand Down
29 changes: 29 additions & 0 deletions spec/tapioca/cli/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,7 @@ def self.gather_constants
Compiling DSL RBI files...

create sorbet/rbi/dsl/job.rbi
Skipping stale RBI removal because `--only` is set.

Done

Expand Down Expand Up @@ -1352,6 +1353,31 @@ module FooModule; end
assert_success_status(result)
end

it "does not remove existing RBI files when using --only" do
@project.write!("lib/job.rb", <<~RB)
require "sidekiq"

class Job
include Sidekiq::Worker
def perform(foo, bar)
end
end
RB

@project.write!("sorbet/rbi/dsl/post.rbi", "# typed: true\n")
@project.write!("sorbet/rbi/dsl/job.rbi", "# typed: true\n")

result = @project.tapioca("dsl --only SidekiqWorker")

assert_project_file_exist("sorbet/rbi/dsl/post.rbi")
assert_project_file_exist("sorbet/rbi/dsl/job.rbi")

assert_includes(result.out, "Skipping stale RBI removal because `--only` is set.")
refute_includes(result.out, "Removing stale RBI files")

assert_success_status(result)
end

it "warns if there are no matching compilers but continues processing" do
@project.write!("lib/post.rb", <<~RB)
require "smart_properties"
Expand All @@ -1373,6 +1399,7 @@ class Post
Warning: Cannot find compiler 'NonexistentCompiler'

create sorbet/rbi/dsl/post.rbi
Skipping stale RBI removal because `--only` is set.

Done

Expand Down Expand Up @@ -1941,6 +1968,7 @@ class Post < ActiveRecord::Base
Compiling DSL RBI files...

create sorbet/rbi/dsl/post.rbi
Skipping stale RBI removal because `--only` is set.

Done

Expand Down Expand Up @@ -3299,6 +3327,7 @@ class Post < ActiveRecord::Base
Compiling DSL RBI files...

create sorbet/rbi/dsl/post.rbi
Skipping stale RBI removal because `--only` is set.

Done

Expand Down
Loading