Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tools/third-party-licenses/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ desktop = ["dep:cef-dll-sys", "dep:scraper", "dep:lzma-rust2"]
serde = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
tempfile = "3"
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.

# Optional workspace dependencies
cef-dll-sys = { workspace = true, optional = true }
Expand Down
9 changes: 6 additions & 3 deletions tools/third-party-licenses/src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ fn parse(parsed: Output) -> Vec<LicenseEntry> {
}

fn run() -> Result<Output, Error> {
let temp_file = tempfile::NamedTempFile::new().map_err(|e| Error::Io(e, "Failed to create temporary file for cargo about output".into()))?;

let output = Command::new("cargo")
.args(["about", "generate", "--format", "json", "--locked"])
.args(["about", "generate", "--format", "json", "--locked", "-o"])
.arg(temp_file.path())
.current_dir(env!("CARGO_WORKSPACE_DIR"))
.output()
.map_err(|e| Error::Io(e, "Failed to run cargo about generate".into()))?;
Expand All @@ -95,7 +98,7 @@ fn run() -> Result<Output, Error> {
return Err(Error::Command(format!("cargo about generate failed:\n{}", String::from_utf8_lossy(&output.stderr))));
}

let stdout = String::from_utf8(output.stdout).map_err(|e| Error::Utf8(e, "cargo about generate returned invalid UTF-8".into()))?;
let file_content = fs::read_to_string(temp_file.path()).map_err(|e| Error::Io(e, format!("Failed to read cargo about output from {}", temp_file.path().display())))?;

serde_json::from_str(&stdout).map_err(|e| Error::Json(e, "Failed to parse cargo about generate JSON".into()))
serde_json::from_str(&file_content).map_err(|e| Error::Json(e, "Failed to parse cargo about generate JSON".into()))
}