mirror of
https://github.com/crate-ci/typos.git
synced 2025-01-24 07:28:57 -05:00
perf(cli): Reuse configs across runs
This commit is contained in:
parent
a76ddd42ce
commit
8365351dba
1 changed files with 10 additions and 10 deletions
20
src/main.rs
20
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)?;
|
||||
|
|
Loading…
Add table
Reference in a new issue