From 9576a7b4905d82d218573358afaf51783be9034c Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Fri, 17 May 2024 12:26:59 +0900 Subject: [PATCH] extend/pathname: restore old rmtree behaviour --- Library/.rubocop.yml | 3 ++- Library/Homebrew/extend/pathname.rb | 2 ++ Library/Homebrew/extend/pathname/rmtree.rb | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 Library/Homebrew/extend/pathname/rmtree.rb diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 0376d206f976be..66674395f5a9c3 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -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: diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 8b0c072d4ccf29..047dd908ee91b1 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -584,3 +584,5 @@ def uninstall_info puts "uninfo #{self}" if ObserverPathnameExtension.verbose? end end + +require "extend/pathname/rmtree" diff --git a/Library/Homebrew/extend/pathname/rmtree.rb b/Library/Homebrew/extend/pathname/rmtree.rb new file mode 100644 index 00000000000000..e691615902d169 --- /dev/null +++ b/Library/Homebrew/extend/pathname/rmtree.rb @@ -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