Skip to content

Commit f3fccb8

Browse files
themadprofessorStuart Reilly
andauthored
refactor: Replace main's self update with a proper step call (#1470)
Co-authored-by: Stuart Reilly <[email protected]>
1 parent bb4afb7 commit f3fccb8

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

src/main.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,17 +187,7 @@ fn run() -> Result<()> {
187187
}
188188
}
189189

190-
// Self-Update step, this will execute only if:
191-
// 1. the `self-update` feature is enabled
192-
// 2. it is not disabled from configuration (env var/CLI opt/file)
193-
#[cfg(feature = "self-update")]
194-
{
195-
let should_self_update = env::var("TOPGRADE_NO_SELF_UPGRADE").is_err() && !config.no_self_update();
196-
197-
if should_self_update {
198-
runner.execute(step::Step::SelfUpdate, "Self Update", || self_update::self_update(&ctx))?;
199-
}
200-
}
190+
step::Step::SelfUpdate.run(&mut runner, &ctx)?;
201191

202192
#[cfg(windows)]
203193
let _self_rename = if config.self_rename() {

src/step.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,9 @@ impl Step {
544544
runner.execute(*self, "SDKMAN!", || unix::run_sdkman(ctx))?
545545
}
546546
SelfUpdate => {
547+
// Self-Update step, this will execute only if:
548+
// 1. the `self-update` feature is enabled
549+
// 2. it is not disabled from configuration (env var/CLI opt/file)
547550
#[cfg(feature = "self-update")]
548551
{
549552
if std::env::var("TOPGRADE_NO_SELF_UPGRADE").is_err() && !ctx.config().no_self_update() {

0 commit comments

Comments
 (0)