From d92ca8fefd8d2b799e06d59a98a2f9ee16253f5c Mon Sep 17 00:00:00 2001 From: phinze Date: Sat, 6 Apr 2013 16:14:04 -0600 Subject: [PATCH] move Caskroom into opt for spotlight goodness --- lib/cask.rb | 14 ++++++++++++-- test/test_helper.rb | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/cask.rb b/lib/cask.rb index 01f1d650a..1d31718cd 100644 --- a/lib/cask.rb +++ b/lib/cask.rb @@ -18,7 +18,11 @@ class Cask end def self.caskroom - HOMEBREW_PREFIX.join "Caskroom" + @@caskroom ||= Pathname('/opt/homebrew-cask/Caskroom') + end + + def self.caskroom=(caskroom) + @@caskroom = caskroom end def self.appdir @@ -39,7 +43,13 @@ class Cask def self.init HOMEBREW_CACHE.mkpath unless HOMEBREW_CACHE.exist? - caskroom.mkpath unless caskroom.exist? + unless caskroom.exist? + ohai "We need to make Caskroom for the first time at #{caskroom}" + ohai "We'll set permissions properly so this is the only time homebrew-cask will ever need sudo" + current_user = ENV['USER'] + system "sudo mkdir -p #{caskroom}" + system "sudo chown #{current_user}:staff #{caskroom.parent}" + end appdir.mkpath unless appdir.exist? end diff --git a/test/test_helper.rb b/test/test_helper.rb index 62cce03c0..e908654a8 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -28,6 +28,9 @@ require 'cask' # look for casks in testcasks by default Cask.default_tap = 'phinze-testcasks' +# our own testy caskroom +Cask.caskroom = HOMEBREW_PREFIX.join('TestCaskroom') + # silence some extraneous UI messages for tests ENV['QUIET_TESTS'] = '1'