remove Homebrew namespaces in homebrew-fork
* remove two Homebrew modules * rename Homebrew.system * rename HomebrewArgvExtension * remove some unused requires still todo: constants starting with HOMEBREW_
This commit is contained in:
parent
cb427e0da3
commit
8eb7de29a2
|
@ -1,4 +1,4 @@
|
|||
module HomebrewArgvExtension
|
||||
module HomebrewForkArgvExtension
|
||||
def verbose?
|
||||
flag? '--verbose' or !ENV['VERBOSE'].nil? or !ENV['HOMEBREW_VERBOSE'].nil?
|
||||
end
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
require 'extend/pathname'
|
||||
require 'extend/ARGV'
|
||||
require 'extend/string'
|
||||
require 'utils'
|
||||
require 'exceptions'
|
||||
require 'set'
|
||||
require 'rbconfig'
|
||||
|
||||
ARGV.extend(HomebrewArgvExtension)
|
||||
ARGV.extend(HomebrewForkArgvExtension)
|
||||
|
||||
def cache
|
||||
if ENV['HOMEBREW_CACHE']
|
||||
|
@ -50,10 +47,3 @@ HOMEBREW_GITHUB_API_TOKEN = ENV["HOMEBREW_GITHUB_API_TOKEN"]
|
|||
HOMEBREW_USER_AGENT = "Homebrew-cask v0.51+ (Ruby #{RUBY_VERSION}-#{RUBY_PATCHLEVEL}; #{MACOS_VERSION})"
|
||||
|
||||
HOMEBREW_CURL_ARGS = '-f#LA'
|
||||
|
||||
module Homebrew
|
||||
extend self
|
||||
|
||||
attr_accessor :failed
|
||||
alias_method :failed?, :failed
|
||||
end
|
||||
|
|
|
@ -28,4 +28,4 @@ MACOS_VERSION = ENV.fetch('MACOS_VERSION') { MACOS_FULL_VERSION[/10\.\d+/] }
|
|||
|
||||
# required for many tests
|
||||
# eg: undefined method `verbose?' for []:Array
|
||||
ARGV.extend(HomebrewArgvExtension)
|
||||
ARGV.extend(HomebrewForkArgvExtension)
|
||||
|
|
|
@ -59,28 +59,26 @@ end
|
|||
|
||||
# :stopdoc:
|
||||
|
||||
module Homebrew
|
||||
def self.system cmd, *args
|
||||
puts "#{cmd} #{args*' '}" if ARGV.verbose?
|
||||
pid = fork do
|
||||
yield if block_given?
|
||||
args.collect!{|arg| arg.to_s}
|
||||
exec(cmd, *args) rescue nil
|
||||
exit! 1 # never gets here unless exec failed
|
||||
end
|
||||
Process.wait(pid)
|
||||
$?.success?
|
||||
def homebrew_fork_system cmd, *args
|
||||
puts "#{cmd} #{args*' '}" if ARGV.verbose?
|
||||
pid = fork do
|
||||
yield if block_given?
|
||||
args.collect!{|arg| arg.to_s}
|
||||
exec(cmd, *args) rescue nil
|
||||
exit! 1 # never gets here unless exec failed
|
||||
end
|
||||
Process.wait(pid)
|
||||
$?.success?
|
||||
end
|
||||
|
||||
# Kernel.system but with exceptions
|
||||
def safe_system cmd, *args
|
||||
Homebrew.system(cmd, *args) or raise ErrorDuringExecution.new(cmd, args)
|
||||
homebrew_fork_system(cmd, *args) or raise ErrorDuringExecution.new(cmd, args)
|
||||
end
|
||||
|
||||
# prints no output
|
||||
def quiet_system cmd, *args
|
||||
Homebrew.system(cmd, *args) do
|
||||
homebrew_fork_system(cmd, *args) do
|
||||
# Redirect output streams to `/dev/null` instead of closing as some programs
|
||||
# will fail to execute if they can't write to an open stream.
|
||||
$stdout.reopen('/dev/null')
|
||||
|
|
Loading…
Reference in New Issue