Skip to content

Commit

Permalink
Show dependencies for casks
Browse files Browse the repository at this point in the history
  • Loading branch information
HaraldNordgren committed Aug 3, 2024
1 parent 4dcd308 commit 1548daa
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Library/Homebrew/cask/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def self.get_info(cask)
output << "#{repo}\n" if repo
output << name_info(cask)
output << desc_info(cask)
deps = deps_info(cask)
output << deps if deps
language = language_info(cask)
output << language if language
output << "#{artifact_info(cask)}\n"
Expand Down Expand Up @@ -76,6 +78,22 @@ def self.desc_info(cask)
EOS
end

sig { params(cask: Cask).returns(T.nilable(String)) }
def self.deps_info(cask)
depends_on = cask.depends_on

cask_deps = depends_on[:cask] ? depends_on[:cask].map { |dep| "#{dep} (cask)" } : []
formula_deps = depends_on[:formula] ? depends_on[:formula].map(&:to_s) : []

all_deps = cask_deps + formula_deps
return if all_deps.empty?

<<~EOS
#{ohai_title("Dependencies")}
#{all_deps.join(", ")}
EOS
end

sig { params(cask: Cask).returns(T.nilable(String)) }
def self.language_info(cask)
return if cask.languages.empty?
Expand Down
19 changes: 19 additions & 0 deletions Library/Homebrew/test/cask/info_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@
EOS
end

it "prints deps if the Cask provided ones" do
expect do
described_class.info(Cask::CaskLoader.load("with-depends-on-cask-multiple"))
end.to output(<<~EOS).to_stdout
==> with-depends-on-cask-multiple: 1.2.3
https://brew.sh/with-depends-on-cask-multiple
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/w/with-depends-on-cask-multiple.rb
==> Name
None
==> Description
None
==> Dependencies
local-caffeine (cask), local-transmission (cask)
==> Artifacts
Caffeine.app (App)
EOS
end

it "prints auto_updates if the Cask has `auto_updates true`" do
expect do
described_class.info(Cask::CaskLoader.load("with-auto-updates"))
Expand Down

0 comments on commit 1548daa

Please sign in to comment.