From afbb8264df500282c7580b79fd9373673f94d50f Mon Sep 17 00:00:00 2001 From: domingo2000 Date: Sat, 11 May 2024 17:12:59 -0400 Subject: [PATCH] add cache option to config file --- lib/erb_lint/cli.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/erb_lint/cli.rb b/lib/erb_lint/cli.rb index ee95c75..7abdf5e 100644 --- a/lib/erb_lint/cli.rb +++ b/lib/erb_lint/cli.rb @@ -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") + end + @cache = Cache.new(@config, cache_dir) if cache? || clear_cache? if clear_cache? @@ -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?