From 66131e9336366bf3700fdc5296eea1d516d23723 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 8 May 2026 00:20:47 +0900 Subject: fix(commands): use tryComposer/createConfig idiom for archive and diagnose MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit archive and diagnose were not honoring $COMPOSER_HOME/config.json because they bypassed Factory::createConfig() — archive used literal "tar"/"." defaults when no composer.json was present, and diagnose reimplemented cache-dir resolution from environment variables. Mirror Composer's tryComposer + Factory::createConfig() fallback so global config (archive-format, archive-dir, cache-dir) applies in both commands. --- crates/mozart/src/commands/diagnose.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'crates/mozart/src/commands/diagnose.rs') diff --git a/crates/mozart/src/commands/diagnose.rs b/crates/mozart/src/commands/diagnose.rs index 0a901e1..8ea2098 100644 --- a/crates/mozart/src/commands/diagnose.rs +++ b/crates/mozart/src/commands/diagnose.rs @@ -1,8 +1,11 @@ use clap::Args; use colored::Colorize; use mozart_core::MOZART_VERSION; +use mozart_core::composer::Composer; use mozart_core::console::Console; use mozart_core::console_writeln; +use mozart_core::factory::create_config; +use std::borrow::Cow; use std::path::{Path, PathBuf}; #[derive(Args)] @@ -391,19 +394,13 @@ pub async fn execute( let mut exit_code: i32 = 0; - // Determine cache directory (same logic as build_cache_config) - let cache_dir = if let Ok(dir) = std::env::var("COMPOSER_CACHE_DIR") { - PathBuf::from(dir) + let composer = Composer::try_load(&working_dir)?; + let config = if let Some(composer) = &composer { + Cow::Borrowed(composer.config()) } else { - let base = if let Ok(xdg) = std::env::var("XDG_CACHE_HOME") { - PathBuf::from(xdg) - } else if let Ok(home) = std::env::var("HOME") { - PathBuf::from(home).join(".cache") - } else { - PathBuf::from("/tmp") - }; - base.join("mozart") + Cow::Owned(create_config()?) }; + let cache_dir = PathBuf::from(&config.cache_dir); // 1. Mozart version info print_info_line(&check_version(), console); -- cgit v1.3.1