diff --git a/Library/Homebrew/cask/lib/hbc/cask.rb b/Library/Homebrew/cask/lib/hbc/cask.rb index 975d69d074fc2005a6ed121d5cf4cf9a9a23bcf2..8b39bdfd5ec5876d89d61c4553efc185d8100960 100644 --- a/Library/Homebrew/cask/lib/hbc/cask.rb +++ b/Library/Homebrew/cask/lib/hbc/cask.rb @@ -84,6 +84,11 @@ module Hbc !versions.empty? end + def installed_caskfile + installed_version = timestamped_versions.last + metadata_master_container_path.join(*installed_version, "Casks", "#{token}.rb") + end + def to_s @token end diff --git a/Library/Homebrew/cask/lib/hbc/cli/list.rb b/Library/Homebrew/cask/lib/hbc/cli/list.rb index 5d7a58b93626bafe2785f27a45b19918514610c0..51ca5dabeb830507fc700c4442faaf407f500410 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/list.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/list.rb @@ -36,8 +36,7 @@ module Hbc elsif @options[:versions] puts format_versioned(cask) else - installed_caskfile = cask.metadata_master_container_path.join(*cask.timestamped_versions.last, "Casks", "#{cask_token}.rb") - cask = Hbc.load(installed_caskfile) + cask = CaskLoader.load_from_file(cask.installed_caskfile) list_artifacts(cask) end diff --git a/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb b/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb index 30d9b694c981035b1030deb3ff53465444bdeab6..c101c9235df863a410d2a8adaad150fb55b5d525 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb @@ -17,16 +17,10 @@ module Hbc if cask.installed? # use copy of cask for uninstallation to avoid 'No such file or directory' bug installed_cask = cask - latest_installed_version = installed_cask.timestamped_versions.last - unless latest_installed_version.nil? - latest_installed_cask_file = installed_cask.metadata_master_container_path - .join(latest_installed_version - .join(File::Separator), - "Casks", "#{cask_token}.rb") - - # use the same cask file that was used for installation, if possible - installed_cask = CaskLoader.load_from_file(latest_installed_cask_file) if latest_installed_cask_file.exist? + # use the same cask file that was used for installation, if possible + if (installed_caskfile = installed_cask.installed_caskfile).exist? + installed_cask = CaskLoader.load_from_file(installed_caskfile) end # Always force uninstallation, ignore method parameter