Skip to content

Commit

Permalink
fix(npm): automatically find binary entrypoint when values are all th…
Browse files Browse the repository at this point in the history
…e same (denoland#16735)
  • Loading branch information
dsherret committed Nov 21, 2022
1 parent c0482e0 commit a300b96
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion cli/node/mod.rs
Expand Up @@ -591,7 +591,7 @@ fn resolve_bin_entry_value<'a>(
Value::Object(o) => {
if let Some(bin_name) = bin_name {
o.get(bin_name)
} else if o.len() == 1 {
} else if o.len() == 1 || o.len() > 1 && o.values().all(|v| v == o.values().next().unwrap()) {
o.values().next()
} else {
o.get(&pkg_req.name)
Expand Down Expand Up @@ -1295,6 +1295,21 @@ mod tests {
)
);

// should resolve since all the values are the same
let value = json!({
"bin1": "./value",
"bin2": "./value",
});
assert_eq!(
resolve_bin_entry_value(
&NpmPackageReq::from_str("test").unwrap(),
None,
&value
)
.unwrap(),
"./value"
);

// should not resolve when specified and is a string
let value = json!("./value");
assert_eq!(
Expand Down

0 comments on commit a300b96

Please sign in to comment.