Skip to content

Commit

Permalink
Merge pull request #1257 from MikeMcQuaid/link_force
Browse files Browse the repository at this point in the history
brew_installer: run `brew link --force` when requested.
  • Loading branch information
MikeMcQuaid authored Oct 10, 2023
2 parents 2b24ca7 + 4d44a4a commit d58b9e2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/bundle/brew_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def install(preinstall: true, no_upgrade: false, verbose: false, force: false)

if installed?
service_change_state!(verbose: verbose) if install_result
link_change_state!(verbose: verbose)
link_change_state!(verbose: verbose, force: force)
end

install_result
Expand Down Expand Up @@ -97,7 +97,7 @@ def service_change_state!(verbose:)
end
end

def link_change_state!(verbose: false)
def link_change_state!(verbose: false, force: false)
case @link
when true
unless linked_and_keg_only?
Expand All @@ -112,7 +112,9 @@ def link_change_state!(verbose: false)
when nil
if unlinked_and_not_keg_only?
puts "Linking #{@name} formula." if verbose
Bundle.system(HOMEBREW_BREW_FILE, "link", @name, verbose: verbose)
link_args = "link"
link_args << "--force" if force
Bundle.system(HOMEBREW_BREW_FILE, *link_args, @name, verbose: verbose)
elsif linked_and_keg_only?
puts "Unlinking #{@name} formula." if verbose
Bundle.system(HOMEBREW_BREW_FILE, "unlink", @name, verbose: verbose)
Expand Down

0 comments on commit d58b9e2

Please sign in to comment.