From 7a7904eb0e69dae04b34119a47a07909288c33d5 Mon Sep 17 00:00:00 2001 From: Boris Remizov Date: Tue, 3 Apr 2018 16:27:56 +0300 Subject: [PATCH] Failover in case of Spotlight disabled --- lib/xcode/install.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/xcode/install.rb b/lib/xcode/install.rb index 7db37c63..102ba754 100644 --- a/lib/xcode/install.rb +++ b/lib/xcode/install.rb @@ -253,12 +253,13 @@ def fetch_seedlist end def installed - unless (`mdutil -s /` =~ /disabled/).nil? - $stderr.puts 'Please enable Spotlight indexing for /Applications.' - exit(1) + if `mdutil -s /` =~ /disabled/ + `find /Applications -name '*.app' -type d -maxdepth 1 -exec sh -c \ +'if [ "$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" \ +"{}/Contents/Info.plist" 2>/dev/null)" == "com.apple.dt.Xcode" ]; then echo "{}"; fi' ';'`.split("\n") + else + `mdfind "kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'" 2>/dev/null`.split("\n") end - - `mdfind "kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'" 2>/dev/null`.split("\n") end def parse_seedlist(seedlist)