Skip to content

Commit

Permalink
Use brew info.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Nov 18, 2024
1 parent 1e03a3a commit ffd70d3
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/tasks/brew.rake
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,16 @@ def dependencies(keys, acc: TopologicalHash.new, pool: nil)
promise = case type
when :cask
Concurrent::Promise.execute(executor: pool) {
capture('brew', 'cat', '--cask', name).lines.reduce([]) do |a, line|
if /depends_on\s+formula:\s*(?:"(?<formula>.*)"|'(?<formula>.*)')/ =~ line
[*a, [:formula, formula]]
elsif /depends_on\s+cask:\s*(?:"(?<cask>.*)"|'(?<cask>.*)')/ =~ line
[*a, [:cask, cask]]
else
a
end
end
json = JSON.parse(capture('brew', 'info', '--json=v2', '--cask', name))
cask = json.fetch('casks').fetch(0)
cask.fetch('depends_on', {}).fetch('casks', []).map { |dep| [:cask, dep] } +
cask.fetch('depends_on', {}).fetch('formulae', []).map { |dep| [:formula, dep] }
}
when :formula
Concurrent::Promise.execute(executor: pool) {
capture('brew', 'deps', name).lines.map { |line| [:formula, line.strip] }
json = JSON.parse(capture('brew', 'info', '--json=v2', '--formula', name))
formula = json.fetch('formulae').fetch(0)
formula.fetch('dependencies', {}).map { |dep| [:formula, dep] }
}
end

Expand Down

0 comments on commit ffd70d3

Please sign in to comment.