mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 07:06:40 +00:00
fix(xbar/brew-updates): show installed cask version(s) correctly
The brew outdated command recently changed the "installed_versions" field on casks from a string to an array, bringing it in line with formula details. This allows it to deal with either string or array values, and show them correctly.
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
# rubocop:disable Layout/LineLength
|
# rubocop:disable Layout/LineLength
|
||||||
|
|
||||||
# <xbar.title>Brew Updates</xbar.title>
|
# <xbar.title>Brew Updates</xbar.title>
|
||||||
# <xbar.version>v2.6.2</xbar.version>
|
# <xbar.version>v2.6.3</xbar.version>
|
||||||
# <xbar.author>Jim Myhrberg</xbar.author>
|
# <xbar.author>Jim Myhrberg</xbar.author>
|
||||||
# <xbar.author.github>jimeh</xbar.author.github>
|
# <xbar.author.github>jimeh</xbar.author.github>
|
||||||
# <xbar.desc>List and manage outdated Homebrew formulas and casks</xbar.desc>
|
# <xbar.desc>List and manage outdated Homebrew formulas and casks</xbar.desc>
|
||||||
@@ -254,13 +254,13 @@ module Brew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Formula
|
class Package
|
||||||
attr_reader :name, :installed_versions, :latest_version,
|
attr_reader :name, :installed_versions, :latest_version,
|
||||||
:pinned, :pinned_version
|
:pinned, :pinned_version
|
||||||
|
|
||||||
def initialize(attributes = {})
|
def initialize(attributes = {})
|
||||||
@name = attributes['name']
|
@name = attributes['name']
|
||||||
@installed_versions = attributes['installed_versions']
|
@installed_versions = Array(attributes['installed_versions'])
|
||||||
@latest_version = attributes['current_version']
|
@latest_version = attributes['current_version']
|
||||||
@pinned = attributes['pinned']
|
@pinned = attributes['pinned']
|
||||||
@pinned_version = attributes['pinned_version']
|
@pinned_version = attributes['pinned_version']
|
||||||
@@ -271,17 +271,8 @@ module Brew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Cask
|
class Formula < Package; end
|
||||||
attr_reader :name, :installed_version, :latest_version
|
class Cask < Package; end
|
||||||
|
|
||||||
def initialize(attributes = {})
|
|
||||||
@name = attributes['name']
|
|
||||||
@installed_version = attributes['installed_versions']
|
|
||||||
@latest_version = attributes['current_version']
|
|
||||||
end
|
|
||||||
|
|
||||||
alias current_version installed_version
|
|
||||||
end
|
|
||||||
|
|
||||||
class FormulaUpdates < Common
|
class FormulaUpdates < Common
|
||||||
prefix '🍻'
|
prefix '🍻'
|
||||||
@@ -550,7 +541,7 @@ module Brew
|
|||||||
] + post_commands
|
] + post_commands
|
||||||
)
|
)
|
||||||
printer.sep
|
printer.sep
|
||||||
printer.item("→ Installed: #{cask.installed_version}")
|
printer.item("→ Installed: #{cask.installed_versions.join(', ')}")
|
||||||
printer.item("↑ Latest: #{cask.latest_version}")
|
printer.item("↑ Latest: #{cask.latest_version}")
|
||||||
printer.sep
|
printer.sep
|
||||||
if upgrade_all_exclude?(cask.name)
|
if upgrade_all_exclude?(cask.name)
|
||||||
@@ -636,11 +627,11 @@ module Brew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def all_formulas
|
def all_formulas
|
||||||
@all_formulas ||= outdated['formulae'].map { |line| Formula.new(line) }
|
@all_formulas ||= outdated['formulae'].map { |f| Formula.new(f) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def casks
|
def casks
|
||||||
@casks ||= outdated['casks'].map { |line| Cask.new(line) }
|
@casks ||= outdated['casks'].map { |c| Cask.new(c) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def greedy_args
|
def greedy_args
|
||||||
|
|||||||
Reference in New Issue
Block a user