Skip to content

Commit

Permalink
look for Brewfile in HOMEBREW_USER_CONFIG_HOME
Browse files Browse the repository at this point in the history
When --global is set, use `$HOMEBREW_USER_CONFIG_HOME/Brewfile` if
it exists before falling back to `~/.Brewfile`.
  • Loading branch information
rrotter committed Jan 2, 2025
1 parent 4bb232b commit 313480a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/bundle/brewfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@ module Brewfile
def path(dash_writes_to_stdout: false, global: false, file: nil)
env_bundle_file_global = ENV.fetch("HOMEBREW_BUNDLE_FILE_GLOBAL", nil)
env_bundle_file = ENV.fetch("HOMEBREW_BUNDLE_FILE", nil)
user_config_home = ENV.fetch("HOMEBREW_USER_CONFIG_HOME", nil)

filename = if global
if env_bundle_file_global.present?
env_bundle_file_global
else
raise "'HOMEBREW_BUNDLE_FILE' cannot be specified with '--global'" if env_bundle_file.present?

Bundle.exchange_uid_if_needed! do
"#{Dir.home}/.Brewfile"
if user_config_home && File.exist?("#{user_config_home}/Brewfile")
"#{user_config_home}/Brewfile"

Check warning on line 19 in lib/bundle/brewfile.rb

View check run for this annotation

Codecov / codecov/patch

lib/bundle/brewfile.rb#L19

Added line #L19 was not covered by tests
else
Bundle.exchange_uid_if_needed! do
"#{Dir.home}/.Brewfile"
end
end
end
elsif file.present?
Expand Down

0 comments on commit 313480a

Please sign in to comment.