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