mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Support passing casks in brew style
.
This commit is contained in:
parent
456e674cd8
commit
2a63ba4060
@ -74,8 +74,33 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def to_formulae_paths
|
def to_formulae_paths
|
||||||
@to_formulae_paths ||= (downcased_unique_named - homebrew_tap_cask_names).map do |name|
|
to_paths(only: :formulae)
|
||||||
Formulary.path(name)
|
end
|
||||||
|
|
||||||
|
# Keep existing paths and try to convert others to tap, formula or cask paths.
|
||||||
|
# If a cask and formula with the same name exist, includes both their paths
|
||||||
|
# unless `only` is specified.
|
||||||
|
def to_paths(only: nil)
|
||||||
|
@to_paths ||= {}
|
||||||
|
@to_paths[only] ||= downcased_unique_named.flat_map do |name|
|
||||||
|
if File.exist?(name)
|
||||||
|
name
|
||||||
|
elsif name.count("/") == 1
|
||||||
|
Tap.fetch(name).path
|
||||||
|
else
|
||||||
|
next Formulary.path(name) if only == :formulae
|
||||||
|
next Cask::CaskLoader.path(name) if only == :casks
|
||||||
|
|
||||||
|
formula_path = Formulary.path(name)
|
||||||
|
cask_path = Cask::CaskLoader.path(name)
|
||||||
|
|
||||||
|
paths = []
|
||||||
|
|
||||||
|
paths << formula_path if formula_path.exist?
|
||||||
|
paths << cask_path if cask_path.exist?
|
||||||
|
|
||||||
|
paths.empty? ? name : paths
|
||||||
|
end
|
||||||
end.uniq.freeze
|
end.uniq.freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -39,12 +39,8 @@ module Homebrew
|
|||||||
|
|
||||||
target = if args.no_named?
|
target = if args.no_named?
|
||||||
nil
|
nil
|
||||||
elsif args.named.any? { |file| File.exist? file }
|
|
||||||
args.named
|
|
||||||
elsif args.named.any? { |tap| tap.count("/") == 1 }
|
|
||||||
args.named.map { |tap| Tap.fetch(tap).path }
|
|
||||||
else
|
else
|
||||||
args.named.to_formulae_paths
|
args.named.to_paths
|
||||||
end
|
end
|
||||||
|
|
||||||
only_cops = args.only_cops
|
only_cops = args.only_cops
|
||||||
|
@ -126,10 +126,9 @@ module Homebrew
|
|||||||
when :print
|
when :print
|
||||||
args << "--debug" if debug
|
args << "--debug" if debug
|
||||||
|
|
||||||
if ENV["CI"]
|
# Don't show the default formatter's progress dots
|
||||||
# Don't show the default formatter's progress dots on CI.
|
# on CI or if only checking a single file.
|
||||||
args << "--format" << "clang"
|
args << "--format" << "clang" if ENV["CI"] || files.count { |f| !f.directory? } == 1
|
||||||
end
|
|
||||||
|
|
||||||
args << "--color" if Tty.color?
|
args << "--color" if Tty.color?
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user