Merge pull request #15729 from dduugg/inreplace-sig

This commit is contained in:
Carlo Cabrera 2023-07-22 13:01:19 +08:00 committed by GitHub
commit aa74840dc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -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

View File

@ -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 = {}