Improve error message for missing PKG source.

This commit is contained in:
Markus Reiter 2020-12-21 15:45:18 +01:00
parent 82c1e6fb0e
commit 8b17017108

View File

@ -42,7 +42,14 @@ module Cask
ohai "Running installer for #{cask}; your password may be necessary." ohai "Running installer for #{cask}; your password may be necessary."
ohai "Package installers may write to any location; options such as --appdir are ignored." ohai "Package installers may write to any location; options such as --appdir are ignored."
unless path.exist? unless path.exist?
raise CaskError, "pkg source file not found: '#{path.relative_path_from(cask.staged_path)}'" pkg = path.relative_path_from(cask.staged_path)
pkgs = Pathname.glob(cask.staged_path/"**"/"*.pkg").map { |path| path.relative_path_from(cask.staged_path) }
message = "Could not find PKG source file '#{pkg}'"
message += ", found #{pkgs.map { |path| "'#{path}'" }.to_sentence} instead" if pkgs.any?
message += "."
raise CaskError, message
end end
args = [ args = [