Skip to content

Commit

Permalink
fix: Fix the parse error when package.json is generated by wasm-bindgen
Browse files Browse the repository at this point in the history
Introduces WasmBindgenPackageJson for deserializing package.json generated by wasm-bindgen
  • Loading branch information
mohebifar committed Nov 24, 2024
1 parent 32e52ca commit bd3caf3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ struct CrateInformation {
max_version: String,
}

#[derive(Deserialize, Debug)]
struct WasmBindgenPackageJson {
dependencies: Option<HashMap<String, String>>,
}

impl Crate {
/// Returns latest wasm-pack version
pub fn return_wasm_pack_latest_version() -> Result<Option<String>> {
Expand Down Expand Up @@ -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::<HashMap<String, String>>(
&fs::read_to_string(&pkg_file_path)?,
)?)
serde_json::from_str::<WasmBindgenPackageJson>(&fs::read_to_string(&pkg_file_path)?)?
.dependencies
} else {
None
};
Expand Down

0 comments on commit bd3caf3

Please sign in to comment.