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:
12
src/main.rs
12
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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user