From f3fccb86c0ce582040352fdf29cbd8bd144f3996 Mon Sep 17 00:00:00 2001 From: Stuart Reilly Date: Tue, 11 Nov 2025 16:31:04 +0000 Subject: [PATCH] refactor: Replace main's self update with a proper step call (#1470) Co-authored-by: Stuart Reilly --- src/main.rs | 12 +----------- src/step.rs | 3 +++ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index fb7a35f9..f73c1bd8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -187,17 +187,7 @@ fn run() -> Result<()> { } } - // Self-Update step, this will execute only if: - // 1. the `self-update` feature is enabled - // 2. it is not disabled from configuration (env var/CLI opt/file) - #[cfg(feature = "self-update")] - { - let should_self_update = env::var("TOPGRADE_NO_SELF_UPGRADE").is_err() && !config.no_self_update(); - - if should_self_update { - runner.execute(step::Step::SelfUpdate, "Self Update", || self_update::self_update(&ctx))?; - } - } + step::Step::SelfUpdate.run(&mut runner, &ctx)?; #[cfg(windows)] let _self_rename = if config.self_rename() { diff --git a/src/step.rs b/src/step.rs index a0f14720..d0f4b774 100644 --- a/src/step.rs +++ b/src/step.rs @@ -544,6 +544,9 @@ impl Step { runner.execute(*self, "SDKMAN!", || unix::run_sdkman(ctx))? } SelfUpdate => { + // Self-Update step, this will execute only if: + // 1. the `self-update` feature is enabled + // 2. it is not disabled from configuration (env var/CLI opt/file) #[cfg(feature = "self-update")] { if std::env::var("TOPGRADE_NO_SELF_UPGRADE").is_err() && !ctx.config().no_self_update() {