diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index d27f7c5761..ffa47e7394 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -47,6 +47,12 @@ module Cask @token_conflicts = token_conflicts @only = only || [] @except = except || [] + + # Clean up `#extract_artifacts` tmp dir when Audit object is destroyed + ObjectSpace.define_finalizer( + self, + proc { FileUtils.remove_entry(@tmpdir) if @tmpdir }, + ) end def run!