Skip to content

Commit b3d33fa

Browse files
satmanduhsbt
authored andcommitted
handle trailing slash in dest
1 parent b900c68 commit b3d33fa

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/fileutils.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,13 +1642,13 @@ def install(src, dest, mode: nil, owner: nil, group: nil, preserve: nil,
16421642
st = File.stat(s)
16431643
unless File.exist?(d) and compare_file(s, d)
16441644
remove_file d, true
1645-
begin
1646-
require 'pathname'
1647-
rescue LoadError
1648-
raise "Cannot load module pathname for determining parent directory for #{d}."
1645+
if d.to_s.end_with?('/')
1646+
mkdir_p d
1647+
copy_file s, d + File.basename(s)
1648+
else
1649+
mkdir_p File.expand_path('..', d)
1650+
copy_file s, d
16491651
end
1650-
mkdir_p Pathname.new(d).parent
1651-
copy_file s, d
16521652
File.utime st.atime, st.mtime, d if preserve
16531653
File.chmod fu_mode(mode, st), d if mode
16541654
File.chown uid, gid, d if uid or gid

0 commit comments

Comments
 (0)