refactor: Replace main's self update with a proper step call (#1470)

Co-authored-by: Stuart Reilly <sreilly@scottlogic.com>
This commit is contained in:
Stuart Reilly
2025-11-11 16:31:04 +00:00
committed by GitHub
parent bb4afb71e9
commit f3fccb86c0
2 changed files with 4 additions and 11 deletions

View File

@@ -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() {

View File

@@ -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() {