From 7741a713e23b72def02075e40e6d70592609b01d Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 14 Oct 2022 20:57:40 -0400 Subject: [PATCH] Avoid checking for updates when executing via stdin (#433) --- src/main.rs | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/main.rs b/src/main.rs index b7d3857f1c..6b1f132287 100644 --- a/src/main.rs +++ b/src/main.rs @@ -367,25 +367,30 @@ fn inner_main() -> Result { println!("Formatted {modifications} files."); } } else { - let (messages, print_messages) = if cli.files == vec![PathBuf::from("-")] { - let filename = cli.stdin_filename.unwrap_or_else(|| "-".to_string()); - let path = Path::new(&filename); - ( - run_once_stdin(&settings, path, cli.fix)?, - !cli.quiet && !cli.fix, - ) - } else { - ( - run_once(&cli.files, &settings, !cli.no_cache, cli.fix)?, - !cli.quiet, - ) - }; - if print_messages { + let (messages, should_print_messages, should_check_updates) = + if cli.files == vec![PathBuf::from("-")] { + let filename = cli.stdin_filename.unwrap_or_else(|| "-".to_string()); + let path = Path::new(&filename); + ( + run_once_stdin(&settings, path, cli.fix)?, + !cli.quiet && !cli.fix, + false, + ) + } else { + ( + run_once(&cli.files, &settings, !cli.no_cache, cli.fix)?, + !cli.quiet, + !cli.quiet, + ) + }; + if should_print_messages { printer.write_once(&messages)?; } #[cfg(feature = "update-informer")] - check_for_updates(); + if should_check_updates { + check_for_updates(); + } if messages.iter().any(|message| !message.fixed) && !cli.exit_zero { return Ok(ExitCode::FAILURE);