Skip to content

Commit

Permalink
feat(brew): adds "greedy-latest" option to Brew (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
luciodaou authored Feb 17, 2024
1 parent 7a3f3a8 commit 8991bc9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@

[brew]
# greedy_cask = true
# greedy_latest = true
# autoremove = true

# Upgrade formulae built from the HEAD branch; `brew upgrade --fetch-HEAD`
Expand Down
10 changes: 10 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ pub struct Flatpak {
#[serde(deny_unknown_fields)]
pub struct Brew {
greedy_cask: Option<bool>,
greedy_latest: Option<bool>,
autoremove: Option<bool>,
fetch_head: Option<bool>,
}
Expand Down Expand Up @@ -1089,6 +1090,15 @@ impl Config {
.unwrap_or(false)
}

/// Whether Brew cask should be greedy_latest
pub fn brew_greedy_latest(&self) -> bool {
self.config_file
.brew
.as_ref()
.and_then(|c| c.greedy_latest)
.unwrap_or(false)
}

/// Whether Brew should autoremove
pub fn brew_autoremove(&self) -> bool {
self.config_file
Expand Down
3 changes: 3 additions & 0 deletions src/steps/os/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ pub fn run_brew_cask(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()>
if ctx.config().brew_cask_greedy() {
brew_args.push("--greedy");
}
if ctx.config().brew_greedy_latest() {
brew_args.push("--greedy-latest");
}
}

variant.execute(run_type).args(&brew_args).status_checked()?;
Expand Down

0 comments on commit 8991bc9

Please sign in to comment.