Skip to content

Commit

Permalink
Merge pull request #1064 from reitermarkus/migrate-caskroom
Browse files Browse the repository at this point in the history
Ask for `sudo` when moving Caskroom.
  • Loading branch information
reitermarkus authored Sep 22, 2016
2 parents 23efbc5 + 530cee4 commit c310557
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Library/Homebrew/cask/lib/hbc/caskroom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ def migrate_caskroom_from_repo_to_prefix
repo_caskroom = Hbc.homebrew_repository.join("Caskroom")
if !Hbc.caskroom.exist? && repo_caskroom.directory?
ohai "Moving Caskroom from HOMEBREW_REPOSITORY to HOMEBREW_PREFIX"
FileUtils.mv repo_caskroom, Hbc.caskroom

if Hbc.caskroom.parent.writable?
FileUtils.mv repo_caskroom, Hbc.caskroom
else
opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom."
system "/usr/bin/sudo", "--", "/bin/mv", "--", repo_caskroom.to_s, Hbc.caskroom.parent.to_s
end
end
end

Expand Down

0 comments on commit c310557

Please sign in to comment.