Merge pull request #5690 from reitermarkus/mkdir

Only create target directory if it doesn’t exist.
This commit is contained in:
Markus Reiter 2019-02-07 22:22:44 +01:00 committed by GitHub
commit 7f312edf57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,13 +40,13 @@ module Cask
end
ohai "Moving #{self.class.english_name} '#{source.basename}' to '#{target}'."
if target.dirname.parent.writable?
if target.dirname.ascend.find(&:directory?).writable?
target.dirname.mkpath
else
command.run!("/bin/mkdir", args: ["-p", target.dirname], sudo: true)
end
if target.parent.writable?
if target.dirname.writable?
FileUtils.move(source, target)
else
command.run!("/bin/mv", args: [source, target], sudo: true)