diff options
| author | Markus Reiter | 2017-03-12 22:24:45 +0100 |
|---|---|---|
| committer | GitHub | 2017-03-12 22:24:45 +0100 |
| commit | ad7c2e5416b032a49f8c889f9f7634ac8c3ffedc (patch) | |
| tree | 37e1cd06e6ed8fac5fadb8505ee70a6ecabae4dc /Library/Homebrew | |
| parent | 159e35b4c5dfae9fd081142195f59c56780b82ca (diff) | |
| parent | 9f7d86b97caf4c9448b19a7a400eb1ad44a8b81e (diff) | |
| download | brew-ad7c2e5416b032a49f8c889f9f7634ac8c3ffedc.tar.bz2 | |
Merge pull request #2328 from reitermarkus/installed-caskfile
Add `#installed_caskfile` method to `Cask` class.
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cask.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/list.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/reinstall.rb | 12 |
3 files changed, 9 insertions, 11 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cask.rb b/Library/Homebrew/cask/lib/hbc/cask.rb index 975d69d07..8b39bdfd5 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 5d7a58b93..51ca5dabe 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 30d9b694c..c101c9235 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 |
