Skip to content

Commit

Permalink
Remove dev-dependencies only feature when publish
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Jun 4, 2023
1 parent 57326f5 commit 945a087
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/cargo/ops/registry.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::cmp;
use std::collections::{BTreeMap, HashSet};
use std::fs::File;
use std::io::{self, BufRead};
Expand All @@ -7,6 +6,7 @@ use std::path::PathBuf;
use std::str;
use std::task::Poll;
use std::time::Duration;
use std::{cmp, str};

use anyhow::{anyhow, bail, format_err, Context as _};
use cargo_util::paths;
Expand Down Expand Up @@ -366,13 +366,34 @@ fn transmit(
return Ok(());
}

fn is_deps_feature(deps: Vec<NewCrateDependency>, feature: &str) -> bool {
if !feature.contains('/') {
return true;
}
let mut iter = feature.split('/');
let dep_name = iter.next().unwrap();
let feature_name = iter.next().unwrap();
for dep in deps.iter() {
if dep.name == dep_name {
if dep.features.contains(&feature_name.to_string()) {
return true;
}
}
}
false
}

let string_features = match manifest.original().features() {
Some(features) => features
.iter()
.map(|(feat, values)| {
(
feat.to_string(),
values.iter().map(|fv| fv.to_string()).collect(),
values
.iter()
.map(|fv| fv.to_string())
.filter(|feat| is_deps_feature(deps.clone(), feat))
.collect(),
)
})
.collect::<BTreeMap<String, Vec<String>>>(),
Expand Down

0 comments on commit 945a087

Please sign in to comment.