committed by
GitHub
parent
065565240e
commit
25b6b97d38
@@ -143,10 +143,10 @@ fn run() -> Result<()> {
|
|||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
{
|
||||||
runner.execute(Step::Brew, "Brew", || unix::run_brew(&ctx))?;
|
runner.execute(Step::Brew, "Brew", || unix::run_brew(&ctx))?;
|
||||||
runner.execute(Step::Brew, "Brew Cask", || unix::run_brew_cask(&ctx))?;
|
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
{
|
{
|
||||||
|
runner.execute(Step::Brew, "Brew Cask", || macos::run_brew_cask(&ctx))?;
|
||||||
runner.execute(Step::MacPorts, "MacPorts", || macos::run_macports(&ctx))?;
|
runner.execute(Step::MacPorts, "MacPorts", || macos::run_macports(&ctx))?;
|
||||||
runner.execute(Step::MicrosoftAutoUpdate, "Microsoft AutoUpdate", || {
|
runner.execute(Step::MicrosoftAutoUpdate, "Microsoft AutoUpdate", || {
|
||||||
macos::run_msupdate(&ctx)
|
macos::run_msupdate(&ctx)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::execution_context::ExecutionContext;
|
use crate::execution_context::ExecutionContext;
|
||||||
use crate::executor::RunType;
|
use crate::executor::{CommandExt, RunType};
|
||||||
use crate::terminal::{print_separator, prompt_yesno};
|
use crate::terminal::{print_separator, prompt_yesno};
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{SkipStep, TopgradeError},
|
error::{SkipStep, TopgradeError},
|
||||||
@@ -19,6 +19,40 @@ pub fn run_msupdate(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
ctx.run_type().execute(msupdate).arg("--install").check_run()
|
ctx.run_type().execute(msupdate).arg("--install").check_run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn run_brew_cask(ctx: &ExecutionContext) -> Result<()> {
|
||||||
|
let brew = require("brew")?;
|
||||||
|
print_separator("Brew Cask");
|
||||||
|
|
||||||
|
let config = ctx.config();
|
||||||
|
let run_type = ctx.run_type();
|
||||||
|
|
||||||
|
let cask_upgrade_exists = Command::new(&brew)
|
||||||
|
.args(&["--repository", "buo/cask-upgrade"])
|
||||||
|
.check_output()
|
||||||
|
.map(|p| Path::new(p.trim()).exists())?;
|
||||||
|
|
||||||
|
let cask_args = if cask_upgrade_exists {
|
||||||
|
let mut args = vec!["cu", "-y"];
|
||||||
|
if config.brew_cask_greedy() {
|
||||||
|
args.push("-a");
|
||||||
|
}
|
||||||
|
args
|
||||||
|
} else {
|
||||||
|
let mut args = vec!["cask", "upgrade"];
|
||||||
|
if config.brew_cask_greedy() {
|
||||||
|
args.push("--greedy");
|
||||||
|
}
|
||||||
|
args
|
||||||
|
};
|
||||||
|
run_type.execute(&brew).args(&cask_args).check_run()?;
|
||||||
|
|
||||||
|
if ctx.config().cleanup() {
|
||||||
|
run_type.execute(&brew).arg("cleanup").check_run()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn run_macports(ctx: &ExecutionContext) -> Result<()> {
|
pub fn run_macports(ctx: &ExecutionContext) -> Result<()> {
|
||||||
require("port")?;
|
require("port")?;
|
||||||
let sudo = ctx.sudo().as_ref().unwrap();
|
let sudo = ctx.sudo().as_ref().unwrap();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
use crate::error::SkipStep;
|
use crate::error::SkipStep;
|
||||||
use crate::error::TopgradeError;
|
use crate::error::TopgradeError;
|
||||||
use crate::execution_context::ExecutionContext;
|
use crate::execution_context::ExecutionContext;
|
||||||
use crate::executor::{CommandExt, ExecutorExitStatus, RunType};
|
use crate::executor::{ExecutorExitStatus, RunType};
|
||||||
use crate::terminal::{print_separator, print_warning};
|
use crate::terminal::{print_separator, print_warning};
|
||||||
use crate::utils::{require, PathExt};
|
use crate::utils::{require, PathExt};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
@@ -11,7 +11,7 @@ use log::debug;
|
|||||||
use std::env;
|
use std::env;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::os::unix::fs::MetadataExt;
|
use std::os::unix::fs::MetadataExt;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
pub fn run_fisher(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
|
pub fn run_fisher(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
|
||||||
@@ -42,40 +42,6 @@ pub fn run_brew(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
.check_run()
|
.check_run()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_brew_cask(ctx: &ExecutionContext) -> Result<()> {
|
|
||||||
let brew = require("brew")?;
|
|
||||||
print_separator("Brew Cask");
|
|
||||||
|
|
||||||
let config = ctx.config();
|
|
||||||
let run_type = ctx.run_type();
|
|
||||||
|
|
||||||
let cask_upgrade_exists = Command::new(&brew)
|
|
||||||
.args(&["--repository", "buo/cask-upgrade"])
|
|
||||||
.check_output()
|
|
||||||
.map(|p| Path::new(p.trim()).exists())?;
|
|
||||||
|
|
||||||
let cask_args = if cask_upgrade_exists {
|
|
||||||
let mut args = vec!["cu", "-y"];
|
|
||||||
if config.brew_cask_greedy() {
|
|
||||||
args.push("-a");
|
|
||||||
}
|
|
||||||
args
|
|
||||||
} else {
|
|
||||||
let mut args = vec!["cask", "upgrade"];
|
|
||||||
if config.brew_cask_greedy() {
|
|
||||||
args.push("--greedy");
|
|
||||||
}
|
|
||||||
args
|
|
||||||
};
|
|
||||||
run_type.execute(&brew).args(&cask_args).check_run()?;
|
|
||||||
|
|
||||||
if ctx.config().cleanup() {
|
|
||||||
run_type.execute(&brew).arg("cleanup").check_run()?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
|
pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
|
||||||
let nix = require("nix")?;
|
let nix = require("nix")?;
|
||||||
let nix_channel = require("nix-channel")?;
|
let nix_channel = require("nix-channel")?;
|
||||||
|
|||||||
Reference in New Issue
Block a user