From ddb0c396734a079de22ca3509a88e2bc8b370637 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Fri, 17 May 2024 01:31:32 +0100 Subject: [PATCH] extend/pathname: restore old rmtree behaviour --- Library/Homebrew/extend/pathname.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 8b0c072d4ccf29..582a254da424e3 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -257,6 +257,17 @@ def stem File.basename(self, extname) end + # Like regular `rmtree`, except it never ignores errors. + # + # This was the default behaviour in Ruby 3.1 and earlier. + # + # @api public + sig { void } + def rmtree(**options) + FileUtils.rm_r(@path, **options) + nil + end + # I don't trust the children.length == 0 check particularly, not to mention # it is slow to enumerate the whole directory just to see if it is empty, # instead rely on good ol' libc and the filesystem