Dynamically find gem groups
This commit is contained in:
parent
b94aede51b
commit
376440cf3e
@ -30,7 +30,7 @@ module Homebrew
|
||||
Homebrew::Settings.delete(:gemgroups) if groups
|
||||
|
||||
groups ||= []
|
||||
groups |= VALID_GEM_GROUPS if groups.delete("all")
|
||||
groups |= Homebrew.valid_gem_groups if groups.delete("all")
|
||||
|
||||
Homebrew.install_bundler_gems!(groups: groups)
|
||||
end
|
||||
|
@ -46,7 +46,7 @@ module Homebrew
|
||||
args = typecheck_args.parse
|
||||
|
||||
update = args.update? || args.update_all?
|
||||
groups = update ? VALID_GEM_GROUPS : ["sorbet"]
|
||||
groups = update ? Homebrew.valid_gem_groups : ["sorbet"]
|
||||
Homebrew.install_bundler_gems!(groups: groups)
|
||||
|
||||
HOMEBREW_LIBRARY_PATH.cd do
|
||||
|
@ -30,7 +30,7 @@ module Homebrew
|
||||
|
||||
Homebrew.install_bundler!
|
||||
|
||||
ENV["BUNDLE_WITH"] = VALID_GEM_GROUPS.join(":")
|
||||
ENV["BUNDLE_WITH"] = Homebrew.valid_gem_groups.join(":")
|
||||
|
||||
# System Ruby does not pick up the correct SDK by default.
|
||||
ENV["SDKROOT"] = MacOS.sdk_path if ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"]
|
||||
|
@ -12,10 +12,26 @@ module Homebrew
|
||||
# After updating this, run `brew vendor-gems --update=--bundler`.
|
||||
HOMEBREW_BUNDLER_VERSION = "2.3.26"
|
||||
|
||||
VALID_GEM_GROUPS = ["sorbet", "prof"].freeze
|
||||
|
||||
module_function
|
||||
|
||||
# @api private
|
||||
def gemfile
|
||||
File.join(ENV.fetch("HOMEBREW_LIBRARY"), "Homebrew", "Gemfile")
|
||||
end
|
||||
|
||||
# @api private
|
||||
def valid_gem_groups
|
||||
install_bundler!
|
||||
require "bundler"
|
||||
|
||||
Bundler.with_unbundled_env do
|
||||
ENV["BUNDLE_GEMFILE"] = gemfile
|
||||
groups = Bundler::Definition.build(Bundler.default_gemfile, Bundler.default_lockfile, false).groups
|
||||
groups.delete(:default)
|
||||
groups.map(&:to_s)
|
||||
end
|
||||
end
|
||||
|
||||
def ruby_bindir
|
||||
"#{RbConfig::CONFIG["prefix"]}/bin"
|
||||
end
|
||||
@ -136,7 +152,7 @@ module Homebrew
|
||||
old_bundle_frozen = ENV.fetch("BUNDLE_FROZEN", nil)
|
||||
old_sdkroot = ENV.fetch("SDKROOT", nil)
|
||||
|
||||
invalid_groups = groups - VALID_GEM_GROUPS
|
||||
invalid_groups = groups - valid_gem_groups
|
||||
raise ArgumentError, "Invalid gem groups: #{invalid_groups.join(", ")}" unless invalid_groups.empty?
|
||||
|
||||
install_bundler!
|
||||
@ -147,7 +163,7 @@ module Homebrew
|
||||
groups |= (Homebrew::Settings.read(:gemgroups)&.split(";") || [])
|
||||
groups.sort!
|
||||
|
||||
ENV["BUNDLE_GEMFILE"] = File.join(ENV.fetch("HOMEBREW_LIBRARY"), "Homebrew", "Gemfile")
|
||||
ENV["BUNDLE_GEMFILE"] = gemfile
|
||||
ENV["BUNDLE_WITH"] = groups.join(" ")
|
||||
ENV["BUNDLE_FROZEN"] = "true"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user