mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
style: add --reset-cache option
This commit is contained in:
parent
2256e547d9
commit
c181c9995e
@ -27,6 +27,8 @@ module Homebrew
|
|||||||
description: "Fix style violations automatically using RuboCop's auto-correct feature."
|
description: "Fix style violations automatically using RuboCop's auto-correct feature."
|
||||||
switch "--display-cop-names",
|
switch "--display-cop-names",
|
||||||
description: "Include the RuboCop cop name for each violation in the output."
|
description: "Include the RuboCop cop name for each violation in the output."
|
||||||
|
switch "--reset-cache",
|
||||||
|
description: "Reset the RuboCop cache."
|
||||||
comma_array "--only-cops",
|
comma_array "--only-cops",
|
||||||
description: "Specify a comma-separated <cops> list to check for violations of only the "\
|
description: "Specify a comma-separated <cops> list to check for violations of only the "\
|
||||||
"listed RuboCop cops."
|
"listed RuboCop cops."
|
||||||
@ -51,7 +53,11 @@ module Homebrew
|
|||||||
except_cops = args.except_cops
|
except_cops = args.except_cops
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
fix: args.fix?, display_cop_names: args.display_cop_names?, debug: args.debug?, verbose: args.verbose?
|
fix: args.fix?,
|
||||||
|
display_cop_names: args.display_cop_names?,
|
||||||
|
reset_cache: args.reset_cache?,
|
||||||
|
debug: args.debug?,
|
||||||
|
verbose: args.verbose?,
|
||||||
}
|
}
|
||||||
if only_cops
|
if only_cops
|
||||||
options[:only_cops] = only_cops
|
options[:only_cops] = only_cops
|
||||||
|
@ -40,6 +40,7 @@ module Homebrew
|
|||||||
fix: false,
|
fix: false,
|
||||||
except_cops: nil, only_cops: nil,
|
except_cops: nil, only_cops: nil,
|
||||||
display_cop_names: false,
|
display_cop_names: false,
|
||||||
|
reset_cache: false,
|
||||||
debug: false, verbose: false)
|
debug: false, verbose: false)
|
||||||
raise ArgumentError, "Invalid output type: #{output_type.inspect}" unless [:print, :json].include?(output_type)
|
raise ArgumentError, "Invalid output type: #{output_type.inspect}" unless [:print, :json].include?(output_type)
|
||||||
|
|
||||||
@ -54,6 +55,7 @@ module Homebrew
|
|||||||
fix: fix,
|
fix: fix,
|
||||||
except_cops: except_cops, only_cops: only_cops,
|
except_cops: except_cops, only_cops: only_cops,
|
||||||
display_cop_names: display_cop_names,
|
display_cop_names: display_cop_names,
|
||||||
|
reset_cache: reset_cache,
|
||||||
debug: debug, verbose: verbose)
|
debug: debug, verbose: verbose)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -71,7 +73,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def run_rubocop(files, output_type,
|
def run_rubocop(files, output_type,
|
||||||
fix: false, except_cops: nil, only_cops: nil, display_cop_names: false,
|
fix: false, except_cops: nil, only_cops: nil, display_cop_names: false, reset_cache: false,
|
||||||
debug: false, verbose: false)
|
debug: false, verbose: false)
|
||||||
Homebrew.install_bundler_gems!
|
Homebrew.install_bundler_gems!
|
||||||
require "rubocop"
|
require "rubocop"
|
||||||
@ -130,6 +132,8 @@ module Homebrew
|
|||||||
|
|
||||||
cache_env = { "XDG_CACHE_HOME" => "#{HOMEBREW_CACHE}/style" }
|
cache_env = { "XDG_CACHE_HOME" => "#{HOMEBREW_CACHE}/style" }
|
||||||
|
|
||||||
|
FileUtils.rm_rf cache_env["XDG_CACHE_HOME"] if reset_cache
|
||||||
|
|
||||||
case output_type
|
case output_type
|
||||||
when :print
|
when :print
|
||||||
args << "--debug" if debug
|
args << "--debug" if debug
|
||||||
|
@ -1207,6 +1207,8 @@ including core code and all formulae.
|
|||||||
Fix style violations automatically using RuboCop's auto-correct feature.
|
Fix style violations automatically using RuboCop's auto-correct feature.
|
||||||
* `--display-cop-names`:
|
* `--display-cop-names`:
|
||||||
Include the RuboCop cop name for each violation in the output.
|
Include the RuboCop cop name for each violation in the output.
|
||||||
|
* `--reset-cache`:
|
||||||
|
Reset the RuboCop cache.
|
||||||
* `--only-cops`:
|
* `--only-cops`:
|
||||||
Specify a comma-separated *`cops`* list to check for violations of only the listed RuboCop cops.
|
Specify a comma-separated *`cops`* list to check for violations of only the listed RuboCop cops.
|
||||||
* `--except-cops`:
|
* `--except-cops`:
|
||||||
|
@ -1662,6 +1662,10 @@ Fix style violations automatically using RuboCop\'s auto\-correct feature\.
|
|||||||
Include the RuboCop cop name for each violation in the output\.
|
Include the RuboCop cop name for each violation in the output\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-\-reset\-cache\fR
|
||||||
|
Reset the RuboCop cache\.
|
||||||
|
.
|
||||||
|
.TP
|
||||||
\fB\-\-only\-cops\fR
|
\fB\-\-only\-cops\fR
|
||||||
Specify a comma\-separated \fIcops\fR list to check for violations of only the listed RuboCop cops\.
|
Specify a comma\-separated \fIcops\fR list to check for violations of only the listed RuboCop cops\.
|
||||||
.
|
.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user