if ~/.cargo/.crates.toml doesn't exists or is empty then the user did not install any applications using Cargo
This commit is contained in:
committed by
GitHub
parent
bf986e313c
commit
11d2b2d4ef
@@ -284,7 +284,7 @@ fn run() -> Result<()> {
|
|||||||
runner.execute(Step::Rustup, "rustup", || generic::run_rustup(&base_dirs, run_type))?;
|
runner.execute(Step::Rustup, "rustup", || generic::run_rustup(&base_dirs, run_type))?;
|
||||||
runner.execute(Step::Dotnet, ".NET", || generic::run_dotnet_upgrade(&ctx))?;
|
runner.execute(Step::Dotnet, ".NET", || generic::run_dotnet_upgrade(&ctx))?;
|
||||||
runner.execute(Step::Choosenim, "choosenim", || generic::run_choosenim(&ctx))?;
|
runner.execute(Step::Choosenim, "choosenim", || generic::run_choosenim(&ctx))?;
|
||||||
runner.execute(Step::Cargo, "cargo", || generic::run_cargo_update(run_type))?;
|
runner.execute(Step::Cargo, "cargo", || generic::run_cargo_update(&ctx))?;
|
||||||
runner.execute(Step::Flutter, "Flutter", || generic::run_flutter_upgrade(run_type))?;
|
runner.execute(Step::Flutter, "Flutter", || generic::run_flutter_upgrade(run_type))?;
|
||||||
runner.execute(Step::Emacs, "Emacs", || emacs.upgrade(run_type))?;
|
runner.execute(Step::Emacs, "Emacs", || emacs.upgrade(run_type))?;
|
||||||
runner.execute(Step::Opam, "opam", || generic::run_opam_update(run_type))?;
|
runner.execute(Step::Opam, "opam", || generic::run_opam_update(run_type))?;
|
||||||
|
|||||||
@@ -10,14 +10,19 @@ use crate::{
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use directories::BaseDirs;
|
use directories::BaseDirs;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use std::io::Write;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::{env, path::Path};
|
use std::{env, path::Path};
|
||||||
|
use std::{fs, io::Write};
|
||||||
use tempfile::tempfile_in;
|
use tempfile::tempfile_in;
|
||||||
|
|
||||||
pub fn run_cargo_update(run_type: RunType) -> Result<()> {
|
pub fn run_cargo_update(ctx: &ExecutionContext) -> Result<()> {
|
||||||
utils::require("cargo")?;
|
utils::require("cargo")?;
|
||||||
|
let toml_file = ctx.base_dirs().home_dir().join(".cargo/.crates.toml").require()?;
|
||||||
|
|
||||||
|
if fs::metadata(toml_file)?.len() == 0 {
|
||||||
|
return Err(SkipStep(String::from(".cargo/.crates.toml exists but empty")).into());
|
||||||
|
}
|
||||||
|
|
||||||
print_separator("Cargo");
|
print_separator("Cargo");
|
||||||
|
|
||||||
@@ -29,7 +34,7 @@ pub fn run_cargo_update(run_type: RunType) -> Result<()> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
run_type
|
ctx.run_type()
|
||||||
.execute(cargo_update)
|
.execute(cargo_update)
|
||||||
.args(&["install-update", "--git", "--all"])
|
.args(&["install-update", "--git", "--all"])
|
||||||
.check_run()
|
.check_run()
|
||||||
|
|||||||
Reference in New Issue
Block a user