committed by
GitHub
parent
1e66a47764
commit
31db02d95a
@@ -2,7 +2,9 @@
|
||||
use crate::error::SkipStep;
|
||||
use crate::error::TopgradeError;
|
||||
use crate::execution_context::ExecutionContext;
|
||||
use crate::executor::{CommandExt, Executor, ExecutorExitStatus, RunType};
|
||||
#[cfg(target_os = "macos")]
|
||||
use crate::executor::CommandExt;
|
||||
use crate::executor::{Executor, ExecutorExitStatus, RunType};
|
||||
use crate::terminal::{print_separator, print_warning};
|
||||
use crate::utils::{require, PathExt};
|
||||
use anyhow::Result;
|
||||
@@ -85,37 +87,52 @@ pub fn run_oh_my_fish(ctx: &ExecutionContext) -> Result<()> {
|
||||
ctx.run_type().execute(&fish).args(&["-c", "omf update"]).check_run()
|
||||
}
|
||||
|
||||
pub fn run_brew(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()> {
|
||||
pub fn run_brew_formula(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()> {
|
||||
require(variant.binary_name())?;
|
||||
print_separator(variant.step_title());
|
||||
let run_type = ctx.run_type();
|
||||
|
||||
variant.execute(run_type).arg("update").check_run()?;
|
||||
variant
|
||||
.execute(run_type)
|
||||
.args(&["upgrade", "--ignore-pinned", "--formula"])
|
||||
.check_run()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
variant.execute(run_type).arg("cleanup").check_run()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn run_brew_cask(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()> {
|
||||
require(variant.binary_name())?;
|
||||
print_separator(format!("{} - Cask", variant.step_title()));
|
||||
let run_type = ctx.run_type();
|
||||
|
||||
let cask_upgrade_exists = variant
|
||||
.execute(RunType::Wet)
|
||||
.args(&["--repository", "buo/cask-upgrade"])
|
||||
.check_output()
|
||||
.map(|p| Path::new(p.trim()).exists())?;
|
||||
|
||||
let mut brew_args = vec!["upgrade", "--ignore-pinned"];
|
||||
let mut brew_args = vec![];
|
||||
|
||||
if cask_upgrade_exists {
|
||||
brew_args.push("--formula")
|
||||
} else if ctx.config().brew_cask_greedy() {
|
||||
brew_args.push("--greedy");
|
||||
}
|
||||
|
||||
variant.execute(run_type).arg("update").check_run()?;
|
||||
variant.execute(run_type).args(&brew_args).check_run()?;
|
||||
|
||||
if cask_upgrade_exists {
|
||||
let mut args = vec!["cu", "-y"];
|
||||
brew_args.extend(&["cu", "-y"]);
|
||||
if ctx.config().brew_cask_greedy() {
|
||||
args.push("-a");
|
||||
brew_args.push("-a");
|
||||
}
|
||||
} else {
|
||||
brew_args.extend(&["--cask", "upgrade"]);
|
||||
if ctx.config().brew_cask_greedy() {
|
||||
brew_args.push("--greedy");
|
||||
}
|
||||
|
||||
variant.execute(run_type).args(&args).check_run()?;
|
||||
}
|
||||
|
||||
variant.execute(run_type).args(&brew_args).check_run()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
variant.execute(run_type).arg("cleanup").check_run()?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user