File tree 2 files changed +14
-3
lines changed
2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 61
61
ENV [ "PATH" ] = path . to_s
62
62
63
63
require "commands"
64
+ require "warnings"
64
65
65
66
internal_cmd = Commands . valid_internal_cmd? ( cmd ) || Commands . valid_internal_dev_cmd? ( cmd ) if cmd
66
67
96
97
begin
97
98
Homebrew . public_send Commands . method_name ( cmd )
98
99
rescue NoMethodError => e
99
- case_error = "undefined method `#{ cmd . downcase } ' for module Homebrew"
100
- odie "Unknown command: brew #{ cmd } " if e . message == case_error
100
+ converted_cmd = cmd . downcase . tr ( "-" , "_" )
101
+ case_error = "undefined method `#{ converted_cmd } ' for module Homebrew"
102
+ private_method_error = "private method `#{ converted_cmd } ' called for module Homebrew"
103
+ odie "Unknown command: brew #{ cmd } " if [ case_error , private_method_error ] . include? ( e . message )
101
104
102
105
raise
103
106
end
Original file line number Diff line number Diff line change @@ -8,7 +8,15 @@ module Kernel
8
8
def require? ( path )
9
9
return false if path . nil?
10
10
11
- require path
11
+ if defined? ( Warnings )
12
+ # Work around require warning when done repeatedly:
13
+ # https://bugs.ruby-lang.org/issues/21091
14
+ Warnings . ignore ( /already initialized constant/ , /previous definition of/ ) do
15
+ require path
16
+ end
17
+ else
18
+ require path
19
+ end
12
20
true
13
21
rescue LoadError => e
14
22
# we should raise on syntax errors but not if the file doesn't exist.
You can’t perform that action at this time.
0 commit comments