mirror of
https://github.com/denoland/deno.git
synced 2024-12-21 23:04:45 -05:00
fix(npm): automatically find binary entrypoint when values are all the same (#16735)
This commit is contained in:
parent
c0482e09c3
commit
a300b968b0
1 changed files with 16 additions and 1 deletions
|
@ -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)
|
||||
|
@ -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!(
|
||||
|
|
Loading…
Reference in a new issue