diff options
| author | Max Howell | 2012-08-27 12:57:34 -0400 |
|---|---|---|
| committer | Max Howell | 2012-08-27 12:57:56 -0400 |
| commit | dc68752d3df8716f24a0b5feb1f728924ee0656d (patch) | |
| tree | 8c8cd15368bb0ba7265d6d4921960cdea39585c3 /Library/Homebrew/macos/xcode.rb | |
| parent | 05094060692616040e5ef6bcd9bb996d4dd46cd0 (diff) | |
| download | brew-dc68752d3df8716f24a0b5feb1f728924ee0656d.tar.bz2 | |
Prevent CLT.version being ""
Also cache the response if N/A as it is slow to keep repeating that. And only do one pkgutil call if possible.
Diffstat (limited to 'Library/Homebrew/macos/xcode.rb')
| -rw-r--r-- | Library/Homebrew/macos/xcode.rb | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/Library/Homebrew/macos/xcode.rb b/Library/Homebrew/macos/xcode.rb index 69f6af894..b7a3a26c9 100644 --- a/Library/Homebrew/macos/xcode.rb +++ b/Library/Homebrew/macos/xcode.rb @@ -163,22 +163,15 @@ module MacOS::CLT extend self end def version + # The pkgutils calls are slow, don't repeat if no CLT installed. + @version if @version_determined + + @version_determined = true # Version string (a pretty damn long one) of the CLT package. # Note, that different ways to install the CLTs lead to different # version numbers. - @version ||= begin - standalone = MacOS.pkgutil_info(STANDALONE_PKG_ID) - from_xcode = MacOS.pkgutil_info(FROM_XCODE_PKG_ID) - - if not standalone.empty? - standalone =~ /version: (.*)$/ - $1 - elsif not from_xcode.empty? - from_xcode =~ /version: (.*)$/ - $1 - else - nil - end - end + @version ||= [STANDALONE_PKG_ID, FROM_XCODE_PKG_ID].find do |id| + MacOS.pkgutil_info(id) =~ /version: (.+)$/ + end && $1 end end |
