Skip to content

Commit

Permalink
Use legacy Caskroom if it exists, but warn of change (Homebrew#21901)
Browse files Browse the repository at this point in the history
If a Caskroom exists at the old location of /opt/homebrew-cask/Caskroom,
use it and warn the user that the default location has changed.

Refs Homebrew#21858, Homebrew#21857, Homebrew#21894
  • Loading branch information
jawshooah authored and chizmw committed Jun 15, 2016
1 parent 50ff0ae commit 3d8f5f2
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion lib/hbc/locations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,30 @@ def self.included(base)
end

module ClassMethods
def legacy_caskroom
@@legacy_caskroom ||= Pathname.new('/opt/homebrew-cask/Caskroom')
end

def default_caskroom
@@default_caskroom ||= homebrew_repository.join('Caskroom')
end

def caskroom
@@caskroom ||= homebrew_repository.join('Caskroom')
@@caskroom ||= begin
if Hbc::Utils.path_occupied?(legacy_caskroom)
opoo <<-EOS.undent
The default Caskroom location has moved to #{default_caskroom}.
Please migrate your Casks to the new location, or if you would like to keep your
Caskroom at #{legacy_caskroom}, add the following to your HOMEBREW_CASK_OPTS:
--caskroom=#{legacy_caskroom}
EOS
legacy_caskroom
else
default_caskroom
end
end
end

def caskroom=(caskroom)
Expand Down

0 comments on commit 3d8f5f2

Please sign in to comment.