Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion tests/all/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ fn it_creates_a_package_json_with_npm_dependencies_provided_by_wasm_bindgen() {
utils::manifest::create_wbg_package_json(
&out_dir,
r#"
{ "foo": "^1.2.3" }
{"dependencies": {"foo": "^1.2.3"}}
"#,
)
.unwrap();
Expand Down