Skip to content

Commit 928d69c

Browse files
committed
Do not force overwrite wrapper, fixes #33
1 parent 6014412 commit 928d69c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/executable-hooks/wrapper.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def install_from(full_gem_path)
3535
bindir = calculate_bindir(options)
3636
destination = calculate_destination(bindir)
3737

38-
if File.exist?(wrapper_path)
38+
if File.exist?(wrapper_path) && !same_file(wrapper_path, destination)
3939
FileUtils.mkdir_p(bindir) unless File.exist?(bindir)
4040
# exception based on Gem::Installer.generate_bin
4141
raise Gem::FilePermissionError.new(bindir) unless File.writable?(bindir)
@@ -44,6 +44,12 @@ def install_from(full_gem_path)
4444
end
4545
end
4646

47+
def same_file(file1, file2)
48+
File.exist?(file1) && File.exist?(file2) &&
49+
File.read(file1) == File.read(file2)
50+
end
51+
private :same_file
52+
4753
def uninstall
4854
destination = calculate_destination(calculate_bindir(options))
4955
FileUtils.rm_f(destination) if File.exist?(destination)

0 commit comments

Comments
 (0)