Skip to content

Commit

Permalink
extend/pathname: restore old rmtree behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo98 authored and MikeMcQuaid committed May 17, 2024
1 parent 7452350 commit 727cf5e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Library/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/extend/pathname.rb
Original file line number Diff line number Diff line change
Expand Up @@ -584,3 +584,5 @@ def uninstall_info
puts "uninfo #{self}" if ObserverPathnameExtension.verbose?
end
end

require "extend/pathname/rmtree"
15 changes: 15 additions & 0 deletions Library/Homebrew/extend/pathname/rmtree.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 727cf5e

Please sign in to comment.