From 5a20878e8b1ec30b60370507117150b3f30bfca0 Mon Sep 17 00:00:00 2001 From: Cristian Oliveira Date: Tue, 17 Dec 2024 00:07:24 +0100 Subject: [PATCH] fix: avoids showing unnecessary configuration warnings (#231) --- src/main.rs | 7 ++++++- tests/watcher_reloads_config_file.rs | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 6a1700d..2ca319d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -225,7 +225,7 @@ fn main() { } pub fn execute_watch_command(watches: Watches, args: Args) { - let config_file_paths = if args.flag_config.is_empty() { + let possible_config_paths = if args.flag_config.is_empty() { let dir = std::env::current_dir().expect("Failed to get current directory"); vec![ dir.join(cli::watch::DEFAULT_FILENAME) @@ -241,6 +241,11 @@ pub fn execute_watch_command(watches: Watches, args: Args) { vec![format!("{}", &args.flag_config)] }; + let config_file_paths = possible_config_paths + .into_iter() + .filter(|path| std::path::Path::new(path).exists()) + .collect::>(); + // This here restarts the watcher if the config file changes let watcher_pid = std::process::id(); let th = std::thread::spawn(move || { diff --git a/tests/watcher_reloads_config_file.rs b/tests/watcher_reloads_config_file.rs index 042f63e..65e33e9 100644 --- a/tests/watcher_reloads_config_file.rs +++ b/tests/watcher_reloads_config_file.rs @@ -32,6 +32,8 @@ fn it_terminates_the_current_running_watcher_when_config_changes() { "The config file change was not triggered {}", output ); + + assert!(!output.contains("Funzzy warning: unknown file/directory")); }, ); }