Skip to content

Commit ece50fd

Browse files
committed
Remove dev-dependencies only feature when publish
1 parent 57326f5 commit ece50fd

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/cargo/ops/registry.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,34 @@ fn transmit(
366366
return Ok(());
367367
}
368368

369+
fn is_deps_feature(deps: &Vec<NewCrateDependency>, feature: &str) -> bool {
370+
if !feature.contains('/') {
371+
return true;
372+
}
373+
let mut iter = feature.split('/');
374+
let dep_name = iter.next().unwrap();
375+
let feature_name = iter.next().unwrap();
376+
for dep in deps.iter() {
377+
if dep.name == dep_name {
378+
if dep.features.contains(&feature_name.to_string()) {
379+
return true;
380+
}
381+
}
382+
}
383+
false
384+
}
385+
369386
let string_features = match manifest.original().features() {
370387
Some(features) => features
371388
.iter()
372389
.map(|(feat, values)| {
373390
(
374391
feat.to_string(),
375-
values.iter().map(|fv| fv.to_string()).collect(),
392+
values
393+
.iter()
394+
.map(|fv| fv.to_string())
395+
.filter(|feat| is_deps_feature(&deps, feat))
396+
.collect(),
376397
)
377398
})
378399
.collect::<BTreeMap<String, Vec<String>>>(),

0 commit comments

Comments
 (0)