Ignore deserialize failed csv record

Such as error: `invalid leading zero in pre-release identifier` caused by 1.2.3-alpha.012.2
This commit is contained in:
Folyd 2022-08-13 00:08:34 +08:00
parent b03c609cc7
commit 1b54b7ae5e

View file

@ -90,7 +90,16 @@ fn default_version() -> Version {
fn read_csv<D: DeserializeOwned>(file: impl Read) -> crate::Result<Vec<D>> {
let mut reader = ReaderBuilder::new().has_headers(true).from_reader(file);
Ok(reader.deserialize().map(|record| record.unwrap()).collect())
Ok(reader
.deserialize()
.filter_map(|record| match record {
Ok(record) => Some(record),
Err(err) => {
println!("Deserialize csv record failed: {:?}", err);
None
}
})
.collect())
}
fn generate_javascript_crates_index(crates: Vec<Crate>, minifier: &Minifier) -> String {