Skip to content

Commit

Permalink
outdate-bundled-gems.rb: Add --all option
Browse files Browse the repository at this point in the history
Unless this option is given, keep other gems that may be used by
`test-bundled-gems`.
  • Loading branch information
nobu committed Jan 9, 2024
1 parent bf10863 commit 72a78ec
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tool/outdate-bundled-gems.rb
Expand Up @@ -24,6 +24,8 @@
ruby_version = $1
when /\A--only=(?:(curdir|srcdir)|all)\z/im
only = $1&.downcase
when /\A--all\z/im
all = true
when /\A-/
raise "#{$0}: unknown option: #{ARGV.first}"
else
Expand Down Expand Up @@ -91,8 +93,14 @@ def each_directory
srcdir = Removal.new(ARGV.shift)
curdir = !srcdir.base || File.identical?(srcdir.base, ".") ? srcdir : Removal.new

unless all
bundled = File.read("#{srcdir.base}gems/bundled_gems").scan(/^(\w\S+)\s+(\S+)/).to_h rescue nil
end

srcdir.glob(".bundle/gems/*/") do |dir|
unless srcdir.exist?("gems/#{File.basename(dir)}.gem")
base = File.basename(dir)
next if bundled && !bundled.key?(base[/\A.+(?=-)/])
unless srcdir.exist?("gems/#{base}.gem")
srcdir.rmdir(dir)
end
end
Expand Down

0 comments on commit 72a78ec

Please sign in to comment.