Add helper functions for --cache and fetch explicitly.

This commit is contained in:
Markus Reiter 2020-07-23 02:43:22 +02:00
parent a895f398ed
commit a6bc9e155a
3 changed files with 8 additions and 6 deletions

View File

@ -6,6 +6,8 @@ require "cask/cmd"
require "cask/cask_loader" require "cask/cask_loader"
module Homebrew module Homebrew
extend Fetch
module_function module_function
def __cache_args def __cache_args
@ -58,7 +60,7 @@ module Homebrew
def print_formula_cache(name) def print_formula_cache(name)
formula = Formulary.factory name formula = Formulary.factory name
if Fetch.fetch_bottle?(formula) if fetch_bottle?(formula)
puts formula.bottle.cached_download puts formula.bottle.cached_download
else else
puts formula.cached_download puts formula.cached_download

View File

@ -5,6 +5,8 @@ require "fetch"
require "cli/parser" require "cli/parser"
module Homebrew module Homebrew
extend Fetch
module_function module_function
def fetch_args def fetch_args
@ -62,7 +64,7 @@ module Homebrew
f.print_tap_action verb: "Fetching" f.print_tap_action verb: "Fetching"
fetched_bottle = false fetched_bottle = false
if Fetch.fetch_bottle?(f) if fetch_bottle?(f)
begin begin
fetch_formula(f.bottle) fetch_formula(f.bottle)
rescue Interrupt rescue Interrupt

View File

@ -2,12 +2,10 @@
module Homebrew module Homebrew
module Fetch module Fetch
module_function
def fetch_bottle?(f) def fetch_bottle?(f)
return true if Homebrew.args.force_bottle? && f.bottle return true if args.force_bottle? && f.bottle
return false unless f.bottle && f.pour_bottle? return false unless f.bottle && f.pour_bottle?
return false if Homebrew.args.build_formula_from_source?(f) return false if args.build_formula_from_source?(f)
return false unless f.bottle.compatible_cellar? return false unless f.bottle.compatible_cellar?
true true