From bbdb72c5d5242e53ddb1f00178abe290e5633b48 Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Fri, 21 Feb 2020 09:56:52 -0500 Subject: [PATCH 1/2] tap-info: list cask tokens in JSON output --- Library/Homebrew/tap.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index f5c9f3c5ae..2c4792a8ef 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -419,7 +419,12 @@ class Tap # 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}. @@ -529,6 +534,7 @@ class Tap "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), "pinned" => pinned?, } From 897f2bc225e71c91aff5cd9073339740493b5cdd Mon Sep 17 00:00:00 2001 From: EricFromCanada Date: Fri, 21 Feb 2020 09:59:07 -0500 Subject: [PATCH 2/2] tap-info: drop commands' `brew(cask)` naming requirement --- Library/Homebrew/tap.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 2c4792a8ef..f89ae6be01 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require "commands" require "extend/cachable" require "readall" require "description_cache_store" @@ -474,17 +475,10 @@ class Tap @command_dir ||= path/"cmd" end - def command_file?(file) - 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 @@ -533,9 +527,9 @@ class Tap "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?, }