Skip to content

Commit fe0b51c

Browse files
committed
Rake task registers database path for rake-cleaning
Rake ships with clean and clobber tasks out of the box. Now the audit Task can be (optionally) registered for cleaning. It defaults to off so no change from current behavior. If opted-in, the audit-database path is added to rake's CLOBBER collection. Clean is meant to remove temporary and generated files that are the result of "normal" application runs. Clobber is intended to be a more exhaustive clean that returns the application's state to a "fresh cloned" state. With these conventions, the ruby advisory db fits more cleanly (ha) into the "clobber" category.
1 parent f8b06eb commit fe0b51c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/bundler/audit/task.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class CommandNotFound < RuntimeError
1212
#
1313
# Initializes the task.
1414
#
15-
def initialize
16-
define
15+
def initialize(clean: false)
16+
define(clean:)
1717
end
1818

1919
#
@@ -88,7 +88,9 @@ def update
8888
#
8989
# Defines the `bundle:audit` and `bundle:audit:update` task.
9090
#
91-
def define
91+
def define(clean:)
92+
register_clean if clean
93+
9294
namespace :bundle do
9395
namespace :audit do
9496
desc 'Checks the Gemfile.lock for insecure dependencies'
@@ -109,6 +111,13 @@ def define
109111
task 'bundler:audit:check' => 'bundle:audit:check'
110112
task 'bundler:audit:update' => 'bundle:audit:update'
111113
end
114+
115+
def register_clean
116+
require 'rake/clean'
117+
require 'bundler/audit/database'
118+
119+
CLOBBER.include Bundler::Audit::Database.path
120+
end
112121
end
113122
end
114123
end

0 commit comments

Comments
 (0)