Skip to content

Commit

Permalink
perf(cli): Reuse configs across runs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed Page committed Mar 30, 2021
1 parent a76ddd4 commit 8365351
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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)?;
Expand Down

0 comments on commit 8365351

Please sign in to comment.