Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tap-info: include cask tokens and all commands in JSON output #7061

Merged
merged 2 commits into from Feb 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions Library/Homebrew/tap.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require "commands"
require "extend/cachable"
require "readall"
require "description_cache_store"
Expand Down Expand Up @@ -419,7 +420,12 @@ def cask_file?(file)

# An array of all {Formula} names of this {Tap}.
def formula_names
@formula_names ||= formula_files.map { |f| formula_file_to_name(f) }
@formula_names ||= formula_files.map(&method(:formula_file_to_name))
end

# An array of all {Cask} tokens of this {Tap}.
def cask_tokens
@cask_tokens ||= cask_files.map(&method(:formula_file_to_name))
end

# path to the directory of all alias files for this {Tap}.
Expand Down Expand Up @@ -469,17 +475,10 @@ def command_dir
@command_dir ||= path/"cmd"
end

def command_file?(file)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used by brew cask ci.

file = Pathname.new(file) unless file.is_a? Pathname
file = file.expand_path(path)
file.parent == command_dir && file.basename.to_s.match?(/^brew(cask)?-/) &&
(file.executable? || file.extname == ".rb")
end

# An array of all commands files of this {Tap}.
def command_files
@command_files ||= if command_dir.directory?
command_dir.children.select(&method(:command_file?))
Commands.find_commands(command_dir)
else
[]
end
Expand Down Expand Up @@ -528,8 +527,9 @@ def to_hash
"official" => official?,
"formula_names" => formula_names,
"formula_files" => formula_files.map(&:to_s),
"command_files" => command_files.map(&:to_s),
"cask_tokens" => cask_tokens,
"cask_files" => cask_files.map(&:to_s),
"command_files" => command_files.map(&:to_s),
"pinned" => pinned?,
}

Expand Down