mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Lazily require some heavy files
This commit is contained in:
parent
af1e60014c
commit
e3372e2a14
@ -1,7 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cask/download"
|
||||
|
||||
module Cask
|
||||
class Cmd
|
||||
class Cache < AbstractCommand
|
||||
@ -24,6 +22,8 @@ module Cask
|
||||
end
|
||||
|
||||
def self.cached_location(cask)
|
||||
require "cask/download"
|
||||
|
||||
Download.new(cask).downloader.cached_location
|
||||
end
|
||||
end
|
||||
|
@ -1,8 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cli/parser"
|
||||
require "cask/auditor"
|
||||
|
||||
module Cask
|
||||
class Cmd
|
||||
class Audit < AbstractCommand
|
||||
@ -35,6 +32,8 @@ module Cask
|
||||
end
|
||||
|
||||
def run
|
||||
require "cask/auditor"
|
||||
|
||||
Homebrew.auditing = true
|
||||
strict = args.new_cask? || args.strict?
|
||||
online = args.new_cask? || args.online?
|
||||
|
@ -1,8 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "system_config"
|
||||
require "diagnostic"
|
||||
|
||||
module Cask
|
||||
class Cmd
|
||||
class Doctor < AbstractCommand
|
||||
@ -15,6 +12,8 @@ module Cask
|
||||
end
|
||||
|
||||
def run
|
||||
require "diagnostic"
|
||||
|
||||
success = true
|
||||
|
||||
checks = Homebrew::Diagnostic::Checks.new(verbose: true)
|
||||
|
@ -1,7 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cask/download"
|
||||
|
||||
module Cask
|
||||
class Cmd
|
||||
class Fetch < AbstractCommand
|
||||
@ -21,6 +19,9 @@ module Cask
|
||||
end
|
||||
|
||||
def run
|
||||
require "cask/download"
|
||||
require "cask/installer"
|
||||
|
||||
options = {
|
||||
force: args.force?,
|
||||
quarantine: args.quarantine?,
|
||||
|
@ -1,7 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "json"
|
||||
require "cask/installer"
|
||||
|
||||
module Cask
|
||||
class Cmd
|
||||
@ -34,6 +33,8 @@ module Cask
|
||||
end
|
||||
|
||||
def self.get_info(cask)
|
||||
require "cask/installer"
|
||||
|
||||
output = +"#{title_info(cask)}\n"
|
||||
output << "#{Formatter.url(cask.homepage)}\n" if cask.homepage
|
||||
output << installation_info(cask)
|
||||
|
@ -23,6 +23,8 @@ module Cask
|
||||
end
|
||||
|
||||
def run
|
||||
require "cask/installer"
|
||||
|
||||
options = {
|
||||
binaries: args.binaries?,
|
||||
verbose: args.verbose?,
|
||||
|
@ -1,5 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cask/dsl"
|
||||
|
||||
module Cask
|
||||
class Cmd
|
||||
class InternalStanza < AbstractInternalCommand
|
||||
|
@ -28,6 +28,7 @@ module Cask
|
||||
require_sha: nil,
|
||||
quarantine: nil
|
||||
)
|
||||
require "cask/installer"
|
||||
|
||||
options = {
|
||||
binaries: binaries,
|
||||
|
@ -29,6 +29,8 @@ module Cask
|
||||
end
|
||||
|
||||
def self.uninstall_casks(*casks, binaries: nil, force: false, verbose: false)
|
||||
require "cask/installer"
|
||||
|
||||
options = {
|
||||
binaries: binaries,
|
||||
force: force,
|
||||
|
@ -100,6 +100,8 @@ module Cask
|
||||
old_cask, new_cask,
|
||||
binaries:, force:, quarantine:, require_sha:, skip_cask_deps:, verbose:
|
||||
)
|
||||
require "cask/installer"
|
||||
|
||||
odebug "Started upgrade process for Cask #{old_cask}"
|
||||
old_config = old_cask.config
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cask/cask_loader"
|
||||
require "delegate"
|
||||
require "formulary"
|
||||
|
||||
module Homebrew
|
||||
module CLI
|
||||
@ -133,6 +135,8 @@ module Homebrew
|
||||
def resolve_keg(name)
|
||||
raise UsageError if name.blank?
|
||||
|
||||
require "keg"
|
||||
|
||||
rack = Formulary.to_rack(name.downcase)
|
||||
|
||||
dirs = rack.directory? ? rack.subdirs : []
|
||||
|
@ -4,7 +4,6 @@ require "env_config"
|
||||
require "cli/args"
|
||||
require "optparse"
|
||||
require "set"
|
||||
require "formula"
|
||||
require "utils/tty"
|
||||
|
||||
COMMAND_DESC_WIDTH = 80
|
||||
|
@ -3,6 +3,7 @@
|
||||
require "cli/parser"
|
||||
require "utils/git"
|
||||
require "formulary"
|
||||
require "software_spec"
|
||||
require "tap"
|
||||
|
||||
def with_monkey_patch
|
||||
|
@ -17,7 +17,7 @@ module Superenv
|
||||
def homebrew_extra_paths
|
||||
paths = []
|
||||
paths += %w[binutils make].map do |f|
|
||||
bin = Formula[f].opt_bin
|
||||
bin = Formulary.factory(f).opt_bin
|
||||
bin if bin.directory?
|
||||
rescue FormulaUnavailableError
|
||||
nil
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
require "digest/md5"
|
||||
require "extend/cachable"
|
||||
require "tab"
|
||||
|
||||
# The Formulary is responsible for creating instances of {Formula}.
|
||||
# It is not meant to be used directly from formulae.
|
||||
@ -30,6 +31,8 @@ module Formulary
|
||||
def self.load_formula(name, path, contents, namespace, flags:)
|
||||
raise "Formula loading disabled by HOMEBREW_DISABLE_LOAD_FORMULA!" if Homebrew::EnvConfig.disable_load_formula?
|
||||
|
||||
require "formula"
|
||||
|
||||
mod = Module.new
|
||||
const_set(namespace, mod)
|
||||
|
||||
|
@ -6,6 +6,7 @@ require "json/add/exception"
|
||||
require "pathname"
|
||||
require "ostruct"
|
||||
require "pp"
|
||||
require "forwardable"
|
||||
|
||||
require_relative "load_path"
|
||||
|
||||
@ -38,6 +39,9 @@ require "env_config"
|
||||
|
||||
require "config"
|
||||
require "os"
|
||||
require "context"
|
||||
require "extend/pathname"
|
||||
require "extend/predicable"
|
||||
require "cli/args"
|
||||
require "messages"
|
||||
|
||||
@ -106,7 +110,6 @@ HOMEBREW_PULL_API_REGEX =
|
||||
HOMEBREW_PULL_OR_COMMIT_URL_REGEX =
|
||||
%r[https://github\.com/([\w-]+)/([\w-]+)?/(?:pull/(\d+)|commit/[0-9a-fA-F]{4,40})].freeze
|
||||
|
||||
require "forwardable"
|
||||
require "PATH"
|
||||
|
||||
ENV["HOMEBREW_PATH"] ||= ENV["PATH"]
|
||||
@ -118,11 +121,7 @@ end.compact.freeze
|
||||
|
||||
require "set"
|
||||
|
||||
require "context"
|
||||
require "extend/pathname"
|
||||
|
||||
require "extend/module"
|
||||
require "extend/predicable"
|
||||
require "extend/string"
|
||||
require "active_support/core_ext/object/blank"
|
||||
require "active_support/core_ext/hash/deep_merge"
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
require "commands"
|
||||
require "extend/cachable"
|
||||
require "readall"
|
||||
require "description_cache_store"
|
||||
|
||||
# A {Tap} is used to extend the formulae provided by Homebrew core.
|
||||
@ -232,6 +231,7 @@ class Tap
|
||||
# @param quiet [Boolean] If set, suppress all output.
|
||||
def install(full_clone: true, quiet: false, clone_target: nil, force_auto_update: nil)
|
||||
require "descriptions"
|
||||
require "readall"
|
||||
|
||||
if official? && DEPRECATED_OFFICIAL_TAPS.include?(repo)
|
||||
odie "#{name} was deprecated. This tap is now empty and all its contents were either deleted or migrated."
|
||||
|
@ -1,6 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative "shared_examples/invalid_option"
|
||||
require "cask/auditor"
|
||||
|
||||
describe Cask::Cmd::Audit, :cask do
|
||||
let(:cask) { Cask::Cask.new("cask") }
|
||||
|
@ -27,23 +27,32 @@ describe "brew extract", :integration_test do
|
||||
end
|
||||
|
||||
it "retrieves the most recent version of formula" do
|
||||
path = target[:path]/"Formula/testball@0.2.rb"
|
||||
expect { brew "extract", "testball", target[:name] }
|
||||
.to be_a_success
|
||||
expect(target[:path]/"Formula/testball@0.2.rb").to exist
|
||||
expect(Formulary.factory(target[:path]/"Formula/testball@0.2.rb").version).to be == "0.2"
|
||||
.to output(/^#{path}$/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
expect(path).to exist
|
||||
expect(Formulary.factory(path).version).to be == "0.2"
|
||||
end
|
||||
|
||||
it "retrieves the specified version of formula" do
|
||||
path = target[:path]/"Formula/testball@0.1.rb"
|
||||
expect { brew "extract", "testball", target[:name], "--version=0.1" }
|
||||
.to be_a_success
|
||||
expect(target[:path]/"Formula/testball@0.1.rb").to exist
|
||||
expect(Formulary.factory(target[:path]/"Formula/testball@0.1.rb").version).to be == "0.1"
|
||||
.to output(/^#{path}$/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
expect(path).to exist
|
||||
expect(Formulary.factory(path).version).to be == "0.1"
|
||||
end
|
||||
|
||||
it "retrieves the compatible version of formula" do
|
||||
expect { brew "extract", "testball", target[:name], "--version=0", "--debug" }
|
||||
.to be_a_success
|
||||
expect(target[:path]/"Formula/testball@0.rb").to exist
|
||||
expect(Formulary.factory(target[:path]/"Formula/testball@0.rb").version).to be == "0.2"
|
||||
path = target[:path]/"Formula/testball@0.rb"
|
||||
expect { brew "extract", "testball", target[:name], "--version=0" }
|
||||
.to output(/^#{path}$/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
expect(path).to exist
|
||||
expect(Formulary.factory(path).version).to be == "0.2"
|
||||
end
|
||||
end
|
||||
|
@ -1,5 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cask/installer"
|
||||
|
||||
module InstallHelper
|
||||
module_function
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cask/config"
|
||||
require "cask/cache"
|
||||
|
||||
require "test/support/helper/cask/fake_system_command"
|
||||
require "test/support/helper/cask/install_helper"
|
||||
|
Loading…
x
Reference in New Issue
Block a user