Show a warning when cargo-update isn't installed (fxi #619)

This commit is contained in:
Roey Darwish Dror
2021-02-08 06:31:14 +02:00
parent 6047236925
commit e38fc78c3b

View File

@@ -1,9 +1,12 @@
#![allow(unused_imports)] #![allow(unused_imports)]
use crate::error::{SkipStep, TopgradeError};
use crate::execution_context::ExecutionContext; use crate::execution_context::ExecutionContext;
use crate::executor::{CommandExt, ExecutorOutput, RunType}; use crate::executor::{CommandExt, ExecutorOutput, RunType};
use crate::terminal::{print_separator, shell}; use crate::terminal::{print_separator, shell};
use crate::utils::{self, PathExt}; use crate::utils::{self, PathExt};
use crate::{
error::{SkipStep, TopgradeError},
terminal::print_warning,
};
use anyhow::Result; use anyhow::Result;
use directories::BaseDirs; use directories::BaseDirs;
use log::debug; use log::debug;
@@ -13,10 +16,16 @@ use std::process::Command;
use tempfile::tempfile_in; use tempfile::tempfile_in;
pub fn run_cargo_update(run_type: RunType) -> Result<()> { pub fn run_cargo_update(run_type: RunType) -> Result<()> {
let cargo_update = utils::require("cargo-install-update")?;
print_separator("Cargo"); print_separator("Cargo");
let cargo_update = match utils::require("cargo-install-update") {
Ok(e) => e,
Err(e) => {
print_warning("cargo-update isn't installed so Topgrade can't upgrade cargo packages.\nInstall cargo-update by running `cargo install cargo-update`");
return Err(e);
}
};
run_type run_type
.execute(cargo_update) .execute(cargo_update)
.args(&["install-update", "--git", "--all"]) .args(&["install-update", "--git", "--all"])