Skip to content

Commit

Permalink
Load dependencies even with -r option
Browse files Browse the repository at this point in the history
  • Loading branch information
pocke committed Jul 14, 2022
1 parent c716255 commit 94300f8
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/rbs/environment_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,23 @@ def initialize(core_root: DEFAULT_CORE_ROOT, repository: Repository.new)
@dirs = []
end

def add(path: nil, library: nil, version: nil)
def add(path: nil, library: nil, version: nil, resolve_dependency: true)
case
when path
dirs << path
when library
libs << Library.new(name: library, version: version)
if resolve_dependency
[Collection::Sources::Rubygems.instance, Collection::Sources::Stdlib.instance].each do |source|
gem = {'name' => library, 'version' => version}
next unless source.has?(gem)

source.dependencies_of(gem)&.each do |dep|
add(library: dep['name'])
end
break
end
end
end
end

Expand All @@ -53,7 +64,7 @@ def add_collection(collection_config)
repository.add(collection_config.repo_path)

collection_config.gems.each do |gem|
add(library: gem['name'], version: gem['version'])
add(library: gem['name'], version: gem['version'], resolve_dependency: false)
end
end

Expand Down

0 comments on commit 94300f8

Please sign in to comment.