diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index fa4e578d2d..f1123f9246 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -2472,11 +2472,20 @@ class Formula # # @see Utils::Inreplace.inreplace # @api public + sig { + params( + paths: T.any(T::Array[T.untyped], String, Pathname), + before: T.nilable(T.any(Regexp, String)), + after: T.nilable(T.any(Pathname, String, Symbol)), + audit_result: T::Boolean, + ).void + } def inreplace(paths, before = nil, after = nil, audit_result = true) # rubocop:disable Style/OptionalBooleanParameter super(paths, before, after, audit_result) rescue Utils::Inreplace::Error => e onoe e.to_s - raise BuildError.new(self, "inreplace", paths, {}) + args = paths.is_a?(Array) ? paths : [paths] + raise BuildError.new(self, "inreplace", args, {}) end protected diff --git a/Library/Homebrew/utils/inreplace.rb b/Library/Homebrew/utils/inreplace.rb index 9e3118a430..c2f627ebea 100644 --- a/Library/Homebrew/utils/inreplace.rb +++ b/Library/Homebrew/utils/inreplace.rb @@ -41,12 +41,12 @@ module Utils params( paths: T.any(T::Array[T.untyped], String, Pathname), before: T.nilable(T.any(Regexp, String)), - after: T.nilable(T.any(String, Symbol)), + after: T.nilable(T.any(Pathname, String, Symbol)), audit_result: T::Boolean, ).void } def inreplace(paths, before = nil, after = nil, audit_result = true) # rubocop:disable Style/OptionalBooleanParameter - after = after.to_s if after.is_a? Symbol + after &&= after.to_s errors = {}