From bd3caf398a607e9b093d3c1ad9229d899aca3af4 Mon Sep 17 00:00:00 2001 From: Mohamad Mohebifar Date: Sun, 24 Nov 2024 16:39:30 -0500 Subject: [PATCH] fix: Fix the parse error when package.json is generated by wasm-bindgen Introduces WasmBindgenPackageJson for deserializing package.json generated by wasm-bindgen --- src/manifest/mod.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/manifest/mod.rs b/src/manifest/mod.rs index bf715a81..795cb05c 100644 --- a/src/manifest/mod.rs +++ b/src/manifest/mod.rs @@ -144,6 +144,11 @@ struct CrateInformation { max_version: String, } +#[derive(Deserialize, Debug)] +struct WasmBindgenPackageJson { + dependencies: Option>, +} + impl Crate { /// Returns latest wasm-pack version pub fn return_wasm_pack_latest_version() -> Result> { @@ -629,9 +634,8 @@ impl CrateData { // we merge the NPM dependencies already specified in it. let existing_deps = if pkg_file_path.exists() { // It's just a map of dependency names to versions - Some(serde_json::from_str::>( - &fs::read_to_string(&pkg_file_path)?, - )?) + serde_json::from_str::(&fs::read_to_string(&pkg_file_path)?)? + .dependencies } else { None };