Skip to content

Commit

Permalink
Customize gem install and uninstall hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
djmarcin committed Apr 23, 2020
1 parent d6f9bd1 commit 53114dd
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions rubygems-plugin/rubygems_plugin.rb
Expand Up @@ -9,10 +9,15 @@ def install(options)
if defined?(Bundler::Installer)
Bundler::Installer.prepend ReshimInstaller
else
maybe_reshim = lambda do |installer|
# If any gems with executables were installed or uninstalled, reshim.
Gem.post_install do |installer|
# Reshim any (potentially) new executables.
installer.spec.executables.each do |executable|
`asdf reshim ruby #{RUBY_VERSION} bin/#{executable}`
end
end
Gem.post_uninstall do |installer|
# Unfortunately, reshimming just the removed executables or
# ruby version doesn't work as of 2020/04/23.
`asdf reshim ruby` if installer.spec.executables.any?
end
Gem.post_install &maybe_reshim
Gem.post_uninstall &maybe_reshim
end

0 comments on commit 53114dd

Please sign in to comment.