diff options
| author | Jack Nagel | 2013-07-21 20:09:55 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-07-21 20:09:55 -0500 |
| commit | 7d16d8c7d665848ebada82fda9c09fc3d1a0daae (patch) | |
| tree | 3ed0a360986ea6d2bffbb378aaf9ebad7cfbe74c /Library/Homebrew/os/mac/xcode.rb | |
| parent | 5a4eefe30addb948570eea9a092047ecee483d81 (diff) | |
| download | homebrew-7d16d8c7d665848ebada82fda9c09fc3d1a0daae.tar.bz2 | |
Cache pkgutil results at the source
Diffstat (limited to 'Library/Homebrew/os/mac/xcode.rb')
| -rw-r--r-- | Library/Homebrew/os/mac/xcode.rb | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index d8ac28a9e..bfac9f9bd 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -182,16 +182,17 @@ module MacOS::CLT extend self !latest_version? end + # Version string (a pretty damn long one) of the CLT package. + # Note, that different ways to install the CLTs lead to different + # version numbers. def version - # The pkgutils calls are slow, don't repeat if no CLT installed. - return @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 ||= [STANDALONE_PKG_ID, FROM_XCODE_PKG_ID].find do |id| - MacOS.pkgutil_info(id) =~ /version: (.+)$/ - end && $1 + @version ||= detect_version + end + + def detect_version + [STANDALONE_PKG_ID, FROM_XCODE_PKG_ID].find do |id| + version = MacOS.pkgutil_info(id)[/version: (.+)$/, 1] + return version if version + end end end |
