Skip to content

Commit

Permalink
Forward cargo package --list warnings (#2186)
Browse files Browse the repository at this point in the history
Forward warnings from `cargo package --list` calls. Motivation is the `crates/jiter` crate in [jiter](https://github.com/pydantic/jiter):

```
$ cargo package --list
warning: readme `../../README.md` appears to be a path outside of the package, but there is already a file named `README.md` in the root of the package. The archived crate will contain the copy in the root of the package. Update the readme to point to the path relative to the root of the package to remove this warning.
```
  • Loading branch information
konstin authored Aug 21, 2024
1 parent 87c915b commit a3e0078
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/source_distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use ignore::overrides::Override;
use normpath::PathExt as _;
use path_slash::PathExt as _;
use std::collections::HashMap;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::str;
Expand Down Expand Up @@ -153,8 +154,9 @@ fn add_crate_to_source_distribution(
skip_cargo_toml: bool,
) -> Result<()> {
let manifest_path = manifest_path.as_ref();
let args = ["package", "--list", "--allow-dirty", "--manifest-path"];
let output = Command::new("cargo")
.args(["package", "--list", "--allow-dirty", "--manifest-path"])
.args(args)
.arg(manifest_path)
.output()
.with_context(|| {
Expand All @@ -172,6 +174,10 @@ fn add_crate_to_source_distribution(
String::from_utf8_lossy(&output.stderr),
);
}
if !output.stderr.is_empty() {
eprintln!("From `cargo {}`:", args.join(" "));
std::io::stderr().write_all(&output.stderr)?;
}

let file_list: Vec<&Path> = str::from_utf8(&output.stdout)
.context("Cargo printed invalid utf-8 ಠ_ಠ")?
Expand Down

0 comments on commit a3e0078

Please sign in to comment.