Skip to content

Commit

Permalink
Print warning when specified gem not found
Browse files Browse the repository at this point in the history
  • Loading branch information
ksss committed Jul 10, 2023
1 parent 6302e0f commit fc8f491
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
10 changes: 7 additions & 3 deletions lib/rbs/collection/config/lockfile_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,14 @@ def generate
end
end

gem_hash[name].dependencies.each do |dep|
if spec = gem_hash[dep.name]
assign_gem(name: dep.name, version: spec.version, src_data: nil, ignored_gems: ignored_gems)
if gem_hash.has_key?(name)
gem_hash[name].dependencies.each do |dep|
if spec = gem_hash[dep.name]
assign_gem(name: dep.name, version: spec.version, src_data: nil, ignored_gems: ignored_gems)
end
end
else
RBS.logger.warn "`#{name}` is specified in rbs_collection.yaml. But, it was not found in Gemfile.lock"
end
end

Expand Down
7 changes: 5 additions & 2 deletions lib/rbs/collection/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ def initialize(lockfile_path:, stdout: $stdout)
def install_from_lockfile
install_to = lockfile.fullpath
install_to.mkpath
lockfile.gems.each_value do |gem|
selected = lockfile.gems.select do |name, gem|
gem[:source].has?(name, gem[:version])
end
selected.each_value do |gem|
gem[:source].install(
dest: install_to,
name: gem[:name],
version: gem[:version],
stdout: stdout
)
end
stdout.puts "It's done! #{lockfile.gems.size} gems' RBSs now installed."
stdout.puts "It's done! #{selected.size} gems' RBSs now installed."
end
end
end
Expand Down
6 changes: 5 additions & 1 deletion lib/rbs/collection/sources/stdlib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ def install(dest:, name:, version:, stdout:)
end

def manifest_of(name, version)
manifest_path = (lookup(name, version) or raise).join('manifest.yaml')
unless path = lookup(name, version)
RBS.logger.warn "`#{name}` is specified in rbs_collection.lock.yaml. But it is not found in #{REPO.dirs.join(",")}"
return
end
manifest_path = path.join('manifest.yaml')
YAML.safe_load(manifest_path.read) if manifest_path.exist?
end

Expand Down

0 comments on commit fc8f491

Please sign in to comment.