dev-cmd/vendor-gems: fix creation of broken symlinks
When the target symlink already points to an existing directory, the `#ln_sf` call creates the symlink inside the intended target directory (which is not what we intend to do here). Let's fix that. Closes #16205
This commit is contained in:
parent
d3d51d3448
commit
d15ccaf92f
@ -59,12 +59,16 @@ module Homebrew
|
|||||||
mechanize
|
mechanize
|
||||||
].each do |gem|
|
].each do |gem|
|
||||||
ohai "gem install #{gem}"
|
ohai "gem install #{gem}"
|
||||||
safe_system "gem", "install", "mechanize", "--install-dir", "vendor",
|
safe_system "gem", "install", gem, "--install-dir", "vendor",
|
||||||
"--no-document", "--no-wrappers", "--ignore-dependencies", "--force"
|
"--no-document", "--no-wrappers", "--ignore-dependencies", "--force"
|
||||||
(HOMEBREW_LIBRARY_PATH/"vendor/gems").cd do
|
(HOMEBREW_LIBRARY_PATH/"vendor/gems").cd do
|
||||||
if (source = Pathname.glob("#{gem}-*/").first)
|
source = Pathname.glob("#{gem}-*/").first
|
||||||
FileUtils.ln_sf source, gem
|
next if source.blank?
|
||||||
end
|
|
||||||
|
# We cannot use `#ln_sf` here because that has unintended consequences when
|
||||||
|
# the symlink we want to create exists and points to an existing directory.
|
||||||
|
FileUtils.rm_f gem
|
||||||
|
FileUtils.ln_s source, gem
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
mechanize-2.9.1/
|
|
||||||
Loading…
x
Reference in New Issue
Block a user