Pass -q to cargo-install if log_level is set to off

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-08-04 23:21:29 +10:00
parent 3d28549fd6
commit b6a539735d
No known key found for this signature in database
GPG key ID: 591C0B03040416D6
3 changed files with 14 additions and 4 deletions

View file

@ -17,4 +17,5 @@ pub struct Options {
pub manifest_path: Option<PathBuf>,
pub cli_overrides: PkgOverride,
pub desired_targets: DesiredTargets,
pub quiet: bool,
}

View file

@ -47,7 +47,7 @@ pub async fn install(
.ok_or_else(|| miette!("No viable targets found, try with `--targets`"))?;
if !opts.dry_run {
install_from_source(package, target, jobserver_client)
install_from_source(package, target, jobserver_client, opts.quiet)
.await
.map(|_| None)
} else {
@ -126,6 +126,7 @@ async fn install_from_source(
package: Package<Meta>,
target: &str,
lazy_jobserver_client: LazyJobserverClient,
quiet: bool,
) -> Result<()> {
let jobserver_client = lazy_jobserver_client.get().await?;
@ -136,13 +137,20 @@ async fn install_from_source(
let mut command = process::Command::new("cargo");
jobserver_client.configure(&mut command);
let mut child = Command::from(command)
.arg("install")
let mut cmd = Command::from(command);
cmd.arg("install")
.arg(package.name)
.arg("--version")
.arg(package.version)
.arg("--target")
.arg(&*target)
.arg(&*target);
if quiet {
cmd.arg("quiet");
}
let mut child = cmd
.spawn()
.into_diagnostic()
.wrap_err("Spawning cargo install failed.")?;

View file

@ -335,6 +335,7 @@ async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
manifest_path: opts.manifest_path.take(),
cli_overrides,
desired_targets,
quiet: opts.log_level == LevelFilter::Off,
});
let tasks: Vec<_> = if !opts.dry_run && !opts.no_confirm {