defensive driving against errors running `hdiutil`

This may not be strictly necessary.  But it should help track
down the `hdiutil` errors, which are persistent, but occasional,
and hard to reproduce. (We pass a flag to `hdiutil` to make
respond in XML.)
This commit is contained in:
Roland Walker 2014-06-14 10:55:04 -04:00
parent 3f4f6580e0
commit 9593e614b5
1 changed files with 6 additions and 1 deletions

View File

@ -57,7 +57,12 @@ class Cask::SystemCommand
def self._parse_plist(command, output)
begin
Plist::parse_xml(output)
raise Plist::ParseError "Empty XML input" unless output =~ %r{\S}
xml = Plist::parse_xml(output)
unless xml.respond_to?(:keys) and xml.keys.size > 0
raise Plist::ParseError "Empty XML output"
end
xml
rescue Plist::ParseError
raise CaskError.new(<<-ERRMSG)
Error parsing plist output from command.