Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check CUSTOM_IMPLEMENTATIONS for all variables. #14951

Merged
merged 1 commit into from Mar 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 9 additions & 7 deletions Library/Homebrew/env_config.rb
@@ -1,6 +1,8 @@
# typed: true
# frozen_string_literal: true

require "set"

module Homebrew
# Helper module for querying Homebrew-specific environment variables.
#
Expand Down Expand Up @@ -421,12 +423,15 @@ def env_method_name(env, hash)
method_name
end

CUSTOM_IMPLEMENTATIONS = %w[
HOMEBREW_MAKE_JOBS
HOMEBREW_CASK_OPTS
].freeze
CUSTOM_IMPLEMENTATIONS = Set.new([
:HOMEBREW_MAKE_JOBS,
:HOMEBREW_CASK_OPTS,
]).freeze

ENVS.each do |env, hash|
# Needs a custom implementation.
next if CUSTOM_IMPLEMENTATIONS.include?(env)

method_name = env_method_name(env, hash)
env = env.to_s

Expand All @@ -435,9 +440,6 @@ def env_method_name(env, hash)
ENV[env].present?
end
elsif hash[:default].present?
# Needs a custom implementation.
next if CUSTOM_IMPLEMENTATIONS.include?(env)

define_method(method_name) do
ENV[env].presence || hash.fetch(:default).to_s
end
Expand Down