cargo: add cleanup step (using cargo-cache) (#371)

This commit is contained in:
Isaac Tay
2023-03-03 19:58:15 +08:00
committed by GitHub
parent 7728819133
commit 9c2d121fc9

View File

@@ -56,7 +56,24 @@ pub fn run_cargo_update(ctx: &ExecutionContext) -> Result<()> {
ctx.run_type() ctx.run_type()
.execute(cargo_update) .execute(cargo_update)
.args(["install-update", "--git", "--all"]) .args(["install-update", "--git", "--all"])
.status_checked() .status_checked()?;
if ctx.config().cleanup() {
let cargo_cache = utils::require("cargo-cache")
.ok()
.or_else(|| cargo_dir.join("bin/cargo-cache").if_exists());
match cargo_cache {
Some(e) => {
ctx.run_type().execute(e).args(["-a"]).status_checked()?;
}
None => {
let message = String::from("cargo-cache isn't installed so Topgrade can't cleanup cargo packages.\nInstall cargo-cache by running `cargo install cargo-cache`");
print_warning(message);
}
}
}
Ok(())
} }
pub fn run_flutter_upgrade(run_type: RunType) -> Result<()> { pub fn run_flutter_upgrade(run_type: RunType) -> Result<()> {