Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions Library/Homebrew/tap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def clear_cache
@repo_var = nil
@formula_dir = nil
@cask_dir = nil
@command_dir = nil
@formula_files = nil
@alias_dir = nil
@alias_files = nil
Expand Down Expand Up @@ -446,10 +447,24 @@ def alias_reverse_table
@alias_reverse_table
end

def command_dir
@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 ||= Pathname.glob("#{path}/cmd/brew{,cask}-*")
.select { |file| file.executable? || file.extname == ".rb" }
@command_files ||= if command_dir.directory?
command_dir.children.select(&method(:command_file?))
else
[]
end
end

# path to the pin record for this {Tap}.
Expand Down