extend/pathname: restore old rmtree behaviour

This commit is contained in:
Bo Anderson 2024-05-17 12:32:29 +09:00 committed by Mike McQuaid
parent 7452350919
commit 727cf5e917
No known key found for this signature in database
4 changed files with 20 additions and 1 deletions

View File

@ -221,7 +221,7 @@ Performance/MethodObjectAsBlock:
RSpec:
Include:
- 'Homebrew/test/**/*'
- "Homebrew/test/**/*"
# Intentionally disabled as it doesn't fit with our code style.
RSpec/AnyInstance:
@ -284,6 +284,7 @@ Sorbet/TrueSigil:
- "/**/{Formula,Casks}/**/*.rb"
- "**/{Formula,Casks}/**/*.rb"
- "Homebrew/test/**/*.rb"
- "Homebrew/extend/pathname/rmtree.rb"
# Require &&/|| instead of and/or
Style/AndOr:

View File

@ -33,6 +33,7 @@ Style/Documentation:
- extend/ENV/super.rb
- extend/kernel.rb
- extend/pathname.rb
- extend/pathname/rmtree.rb
- formula.rb
- formula_assertions.rb
- formula_free_port.rb

View File

@ -584,3 +584,5 @@ module ObserverPathnameExtension
puts "uninfo #{self}" if ObserverPathnameExtension.verbose?
end
end
require "extend/pathname/rmtree"

View File

@ -0,0 +1,15 @@
# typed: false
# frozen_string_literal: true
class Pathname
# Like regular `rmtree`, except it never ignores errors.
#
# This was the default behaviour in Ruby 3.1 and earlier.
#
# @api public
def rmtree(noop: nil, verbose: nil, secure: nil)
# odeprecated "rmtree", "FileUtils#rm_r"
FileUtils.rm_r(@path, noop:, verbose:, secure:)
nil
end
end