Skip to content

Commit bd3caf3

Browse files
committed
fix: Fix the parse error when package.json is generated by wasm-bindgen
Introduces WasmBindgenPackageJson for deserializing package.json generated by wasm-bindgen
1 parent 32e52ca commit bd3caf3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/manifest/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ struct CrateInformation {
144144
max_version: String,
145145
}
146146

147+
#[derive(Deserialize, Debug)]
148+
struct WasmBindgenPackageJson {
149+
dependencies: Option<HashMap<String, String>>,
150+
}
151+
147152
impl Crate {
148153
/// Returns latest wasm-pack version
149154
pub fn return_wasm_pack_latest_version() -> Result<Option<String>> {
@@ -629,9 +634,8 @@ impl CrateData {
629634
// we merge the NPM dependencies already specified in it.
630635
let existing_deps = if pkg_file_path.exists() {
631636
// It's just a map of dependency names to versions
632-
Some(serde_json::from_str::<HashMap<String, String>>(
633-
&fs::read_to_string(&pkg_file_path)?,
634-
)?)
637+
serde_json::from_str::<WasmBindgenPackageJson>(&fs::read_to_string(&pkg_file_path)?)?
638+
.dependencies
635639
} else {
636640
None
637641
};

0 commit comments

Comments
 (0)