Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix reshim behavior on gem uninstall and bundle install.
- Loading branch information
Showing
1 changed file
with
16 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
# Yes borrowed from rbenv. Couldn't take my mind off that implementation | ||
|
||
Gem.post_install do |installer| | ||
module ReshimInstaller | ||
def install(options) | ||
super | ||
# We don't know which gems were installed, so always reshim. | ||
`asdf reshim ruby` | ||
end | ||
end | ||
|
||
if installer.spec.executables.any? && installer.bin_dir == Gem.default_bindir | ||
installer.spec.executables.each do |executable| | ||
`asdf reshim ruby #{RUBY_VERSION} bin/#{executable}` | ||
if defined?(Bundler::Installer) | ||
Bundler::Installer.prepend ReshimInstaller | ||
else | ||
maybe_reshim = lambda do |installer| | ||
# If any gems with executables were installed or uninstalled, reshim. | ||
if installer.spec.executables.any? | ||
`asdf reshim ruby` | ||
end | ||
end | ||
|
||
Gem.post_install &maybe_reshim | ||
Gem.post_uninstall &maybe_reshim | ||
end |