diff --git a/src/main.rs b/src/main.rs index a34197a..a94dcd6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -130,11 +130,16 @@ fn handle_main_command( terminal: &mut Terminal>, args: Args, ) -> Result<()> { - let config_file_path = dirs::home_dir() - .context("Unable to get home directory")? - .join(".config") - .join("donkeytype") - .join("donkeytype-config.json"); + let config_file_path = if cfg!(target_os = "windows") { + dirs::config_local_dir().context("Unable to get local config directory")? + } else { + dirs::home_dir() + .context("Unable to get home directory")? + .join(".config") + } + .join("donkeytype") + .join("donkeytype-config.json"); + let config = Config::new(args, config_file_path).context("Unable to create config")?; let expected_input = ExpectedInput::new(&config).context("Unable to create expected input")?; @@ -234,11 +239,15 @@ mod tests { } fn setup_terminal(args: Args) -> Result<(Config, ExpectedInput, Terminal)> { - let config_file_path = dirs::home_dir() - .context("Unable to get home directory")? - .join(".config") - .join("donkeytype") - .join("donkeytype-config.json"); + let config_file_path = if cfg!(target_os = "windows") { + dirs::config_local_dir().context("Unable to get local config directory")? + } else { + dirs::home_dir() + .context("Unable to get home directory")? + .join(".config") + } + .join("donkeytype") + .join("donkeytype-config.json"); let config = Config::new(args, config_file_path).context("Unable to create config")?; let expected_input = diff --git a/src/test_results.rs b/src/test_results.rs index e9164eb..0b34479 100644 --- a/src/test_results.rs +++ b/src/test_results.rs @@ -404,11 +404,15 @@ fn render_chart( } fn get_results_dir_path() -> Result { - let dir_path = dirs::home_dir() - .context("Unable to get home directory")? - .join(".local") - .join("share") - .join("donkeytype"); + let dir_path = if cfg!(target_os = "windows") { + dirs::config_local_dir().context("Unable to get local config directory")? + } else { + dirs::home_dir() + .context("Unable to get home directory")? + .join(".local") + .join("share") + } + .join("donkeytype"); Ok(dir_path) }