Skip to content

Commit

Permalink
Merge pull request #15800 from dduugg/inreplace-paths
Browse files Browse the repository at this point in the history
Narrow member type of inreplace paths enumerable
  • Loading branch information
MikeMcQuaid authored Aug 1, 2023
2 parents 8a74f83 + b26c091 commit 7994173
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2556,7 +2556,7 @@ def install; end
# @api public
sig {
params(
paths: T.any(T::Enumerable[T.untyped], String, Pathname),
paths: T.any(T::Enumerable[T.any(String, Pathname)], String, Pathname),
before: T.nilable(T.any(Pathname, Regexp, String)),
after: T.nilable(T.any(Pathname, String, Symbol)),
audit_result: T::Boolean,
Expand Down
7 changes: 4 additions & 3 deletions Library/Homebrew/utils/inreplace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,22 @@ def initialize(errors)
# @api public
sig {
params(
paths: T.any(T::Array[T.untyped], String, Pathname),
paths: T.any(T::Enumerable[T.any(String, Pathname)], String, Pathname),
before: T.nilable(T.any(Pathname, 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
paths = Array(paths)
after &&= after.to_s
before = before.to_s if before.is_a?(Pathname)

errors = {}

errors["`paths` (first) parameter"] = ["`paths` was empty"] if paths.blank?
errors["`paths` (first) parameter"] = ["`paths` was empty"] if paths.all?(&:blank?)

Array(paths).each do |path|
paths.each do |path|
str = File.binread(path)
s = StringInreplaceExtension.new(str)

Expand Down

0 comments on commit 7994173

Please sign in to comment.