Skip to content

Commit

Permalink
Merge pull request #5690 from reitermarkus/mkdir
Browse files Browse the repository at this point in the history
Only create target directory if it doesn’t exist.
  • Loading branch information
reitermarkus authored Feb 7, 2019
2 parents 29fd1d0 + e09eaf5 commit 7f312ed
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Library/Homebrew/cask/artifact/moved.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ def move(force: false, command: nil, **options)
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)
Expand Down

0 comments on commit 7f312ed

Please sign in to comment.