From 8365351dba3e72460a9a5252fd6304d058943166 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 29 Mar 2021 13:40:46 -0500 Subject: [PATCH] perf(cli): Reuse configs across runs --- src/main.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index 183d20d..5cddf7c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -85,6 +85,16 @@ fn run_dump_config(args: &args::Args, output_path: &std::path::Path) -> proc_exi fn run_checks(args: &args::Args) -> proc_exit::ExitResult { let global_cwd = std::env::current_dir()?; + let storage = typos_cli::policy::ConfigStorage::new(); + let mut overrides = config::EngineConfig::default(); + overrides.update(&args.overrides); + let mut engine = typos_cli::policy::ConfigEngine::new(&storage); + engine.set_isolated(args.isolated).set_overrides(overrides); + if let Some(path) = args.custom_config.as_ref() { + let custom = config::Config::from_file(path).with_code(proc_exit::Code::CONFIG_ERR)?; + engine.set_custom_config(custom); + } + let mut typos_found = false; let mut errors_found = false; for path in args.path.iter() { @@ -101,16 +111,6 @@ fn run_checks(args: &args::Args) -> proc_exit::ExitResult { path.as_path() }; - let storage = typos_cli::policy::ConfigStorage::new(); - let mut overrides = config::EngineConfig::default(); - overrides.update(&args.overrides); - let mut engine = typos_cli::policy::ConfigEngine::new(&storage); - engine.set_isolated(args.isolated).set_overrides(overrides); - if let Some(path) = args.custom_config.as_ref() { - let custom = config::Config::from_file(path).with_code(proc_exit::Code::CONFIG_ERR)?; - engine.set_custom_config(custom); - } - engine .init_dir(cwd) .with_code(proc_exit::Code::CONFIG_ERR)?;