Batch up mdfind calls when possible
This commit is contained in:
parent
97ca3baedc
commit
0d3121f781
@ -438,7 +438,7 @@ end
|
|||||||
|
|
||||||
def check_xcode_select_path
|
def check_xcode_select_path
|
||||||
if not MacOS::CLT.installed? and not File.file? "#{MacOS::Xcode.folder}/usr/bin/xcodebuild"
|
if not MacOS::CLT.installed? and not File.file? "#{MacOS::Xcode.folder}/usr/bin/xcodebuild"
|
||||||
path = MacOS.app_with_bundle_id(MacOS::Xcode::V4_BUNDLE_ID) || MacOS.app_with_bundle_id(MacOS::Xcode::V3_BUNDLE_ID)
|
path = MacOS.app_with_bundle_id(MacOS::Xcode::V4_BUNDLE_ID, MacOS::Xcode::V3_BUNDLE_ID)
|
||||||
path = '/Developer' if path.nil? or not path.directory?
|
path = '/Developer' if path.nil? or not path.directory?
|
||||||
<<-EOS.undent
|
<<-EOS.undent
|
||||||
Your Xcode is configured with an invalid path.
|
Your Xcode is configured with an invalid path.
|
||||||
|
@ -269,22 +269,26 @@ module OS
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
def app_with_bundle_id id
|
def app_with_bundle_id(*ids)
|
||||||
path = mdfind(id).first
|
path = mdfind(*ids).first
|
||||||
Pathname.new(path) unless path.nil? or path.empty?
|
Pathname.new(path) unless path.nil? or path.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def mdfind id
|
def mdfind(*ids)
|
||||||
return [] unless OS.mac?
|
return [] unless OS.mac?
|
||||||
(@mdfind ||= {}).fetch(id.to_s) do |key|
|
(@mdfind ||= {}).fetch(ids) do
|
||||||
@mdfind[key] = `/usr/bin/mdfind "kMDItemCFBundleIdentifier == '#{key}'"`.split("\n")
|
@mdfind[ids] = `/usr/bin/mdfind "#{mdfind_query(*ids)}"`.split("\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def pkgutil_info id
|
def pkgutil_info(id)
|
||||||
(@pkginfo ||= {}).fetch(id.to_s) do |key|
|
(@pkginfo ||= {}).fetch(id.to_s) do |key|
|
||||||
@pkginfo[key] = `/usr/sbin/pkgutil --pkg-info "#{key}" 2>/dev/null`.strip
|
@pkginfo[key] = `/usr/sbin/pkgutil --pkg-info "#{key}" 2>/dev/null`.strip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mdfind_query(*ids)
|
||||||
|
ids.map! { |id| "kMDItemCFBundleIdentifier == #{id}" }.join(" || ")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -70,7 +70,7 @@ module OS
|
|||||||
# helper tools and installed Xcode in a non-conventional place, this
|
# helper tools and installed Xcode in a non-conventional place, this
|
||||||
# is our only option. See: http://superuser.com/questions/390757
|
# is our only option. See: http://superuser.com/questions/390757
|
||||||
def bundle_path
|
def bundle_path
|
||||||
MacOS.app_with_bundle_id(V4_BUNDLE_ID) || MacOS.app_with_bundle_id(V3_BUNDLE_ID)
|
MacOS.app_with_bundle_id(V4_BUNDLE_ID, V3_BUNDLE_ID)
|
||||||
end
|
end
|
||||||
|
|
||||||
def installed?
|
def installed?
|
||||||
|
@ -52,7 +52,7 @@ module OS
|
|||||||
end
|
end
|
||||||
|
|
||||||
def bundle_path
|
def bundle_path
|
||||||
MacOS.app_with_bundle_id(FORGE_BUNDLE_ID) || MacOS.app_with_bundle_id(APPLE_BUNDLE_ID)
|
MacOS.app_with_bundle_id(FORGE_BUNDLE_ID, APPLE_BUNDLE_ID)
|
||||||
end
|
end
|
||||||
|
|
||||||
def version_from_mdls(path)
|
def version_from_mdls(path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user