Skip to content

Commit

Permalink
Add config option for Elan self-update
Browse files Browse the repository at this point in the history
  • Loading branch information
grahnen committed Dec 9, 2024
1 parent 4df30c2 commit 8c80c7a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
18 changes: 18 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,12 @@ pub struct Composer {
self_update: Option<bool>,
}

#[derive(Deserialize, Default, Debug, Merge)]
#[serde(deny_unknown_fields)]
pub struct Elan {
self_update: Option<bool>,
}

#[derive(Deserialize, Default, Debug, Merge)]
#[serde(deny_unknown_fields)]
pub struct Vim {
Expand Down Expand Up @@ -509,6 +515,9 @@ pub struct ConfigFile {
#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
deno: Option<Deno>,

#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
elan: Option<Elan>,

#[merge(strategy = crate::utils::merge_strategies::inner_merge_opt)]
vim: Option<Vim>,

Expand Down Expand Up @@ -1245,6 +1254,15 @@ impl Config {
.unwrap_or(false)
}

/// Whether Elan should update itself
pub fn elan_self_update(&self) -> bool {
self.config_file
.elan
.as_ref()
.and_then(|c| c.self_update)
.unwrap_or(true)
}

/// Whether to force plug update in Vim
pub fn force_vim_plug_update(&self) -> bool {
self.config_file
Expand Down
10 changes: 6 additions & 4 deletions src/steps/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,12 @@ pub fn run_elan(ctx: &ExecutionContext) -> Result<()> {
let elan = require("elan")?;

print_separator("elan");
ctx.run_type()
.execute(&elan)
.args(["self", "update"])
.status_checked()?;
if ctx.config().elan_self_update() {
ctx.run_type()
.execute(&elan)
.args(["self", "update"])
.status_checked()?;
}
ctx.run_type().execute(&elan).arg("update").status_checked()
}

Expand Down

0 comments on commit 8c80c7a

Please sign in to comment.