fix(cli): correctly remove Cargo features (#7013)

This commit is contained in:
Lucas Fernandes Nogueira 2023-05-19 20:12:11 -07:00 committed by GitHub
parent 61e3ad89e9
commit 1253bbf7ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View File

@ -0,0 +1,6 @@
---
'cli.rs': 'patch'
'cli.js': 'patch'
---
Fixes Cargo.toml feature rewriting.

View File

@ -146,14 +146,15 @@ fn write_features(
}
// remove features that shouldn't be in the manifest anymore
let mut i = 0;
while i < features_array.len() {
if let Some(f) = features_array.get(i).and_then(|f| f.as_str()) {
let mut i = features_array.len();
while i != 0 {
let index = i - 1;
if let Some(f) = features_array.get(index).and_then(|f| f.as_str()) {
if !features.contains(f) {
features_array.remove(i);
features_array.remove(index);
}
}
i += 1;
i -= 1;
}
} else {
*manifest_features = Item::Value(Value::Array(toml_array(features)));