aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart/src/commands/diagnose.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-08 00:20:47 +0900
committernsfisis <nsfisis@gmail.com>2026-05-08 00:20:47 +0900
commit66131e9336366bf3700fdc5296eea1d516d23723 (patch)
tree8f8a1d0c0b5f1453f7953fb9cb08936b8a79afbf /crates/mozart/src/commands/diagnose.rs
parent7bfbe47a4baef04072a3593f3f85e4c514214afe (diff)
downloadphp-mozart-66131e9336366bf3700fdc5296eea1d516d23723.tar.gz
php-mozart-66131e9336366bf3700fdc5296eea1d516d23723.tar.zst
php-mozart-66131e9336366bf3700fdc5296eea1d516d23723.zip
fix(commands): use tryComposer/createConfig idiom for archive and diagnose
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.
Diffstat (limited to 'crates/mozart/src/commands/diagnose.rs')
-rw-r--r--crates/mozart/src/commands/diagnose.rs19
1 files changed, 8 insertions, 11 deletions
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);