Skip to content

Update target-specific deps #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2025
Merged
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
50 changes: 43 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,11 @@ https://github.com/rust-analyzer/rustc-auto-publish
// at the `vers` specified above
// * Update the name of `path` dependencies to what we're publishing,
// which is crates with a prefix.
if let Some(deps) = toml.remove("dependencies") {
let update_dependencies = |deps: toml::Value| -> toml::Value {
let deps = deps
.as_table()
.unwrap()
.iter()
.into_iter()
.map(|(name, dep)| {
let table = match dep.as_table() {
Some(s) if s.contains_key("path") => s,
Expand All @@ -478,11 +478,47 @@ https://github.com/rust-analyzer/rustc-auto-publish
}
(name.clone(), new_table.into())
})
.collect::<Vec<_>>();
toml.insert(
"dependencies".to_string(),
toml::Value::Table(deps.into_iter().collect()),
);
.collect();
toml::Value::Table(deps)
};

if let Some(deps) = toml.remove("dependencies") {
toml.insert("dependencies".to_string(), update_dependencies(deps));
}
if let Some(deps) = toml.remove("dev-dependencies") {
toml.insert("dev-dependencies".to_string(), update_dependencies(deps));
}
if let Some(target) = toml.remove("target") {
let target = if let Some(target) = target.as_table() {
toml::Value::Table(
target
.into_iter()
.map(|(name, value)| {
(name.clone(), {
if let Some(table) = value.as_table() {
let mut table = table.clone();
let table =
if let Some(dev_deps) = table.remove("dev-dependencies") {
table.insert(
"dev-dependencies".to_string(),
update_dependencies(dev_deps.clone()),
);
table
} else {
table.clone()
};
toml::Value::Table(table)
} else {
value.clone()
}
})
})
.collect(),
)
} else {
target
};
toml.insert("target".to_string(), target);
}
}

Expand Down