Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cache option to config file #351

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lib/erb_lint/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@ def run(args = ARGV)
dupped_args = args.dup
load_options(dupped_args)

if cache? && autocorrect?
failure!("cannot run autocorrect mode with cache")
end

@files = @options[:stdin] || dupped_args

load_config

cache_dir = @options[:cache_dir]
if cache? && autocorrect?
failure!("cannot run autocorrect mode with cache")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not fail here. It was a bit annoying when options were passed on the command line but with the options in the config file, it will be even less easy to get out of the problem.
The cache shouldn't be enabled, and we should also handle the clear cache option.

end

@cache = Cache.new(@config, cache_dir) if cache? || clear_cache?

if clear_cache?
Expand Down Expand Up @@ -148,7 +147,11 @@ def autocorrect?
end

def cache?
@options[:cache]
@config.to_hash.dig("cache", "enabled") || @options[:cache]
end

def cache_dir
@config.to_hash.dig("cache", "dir") || @options[:cache_dir]
end

def clear_cache?
Expand Down
Loading