-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: root package has peer dependency on itself (#70)
- Loading branch information
1 parent
e0c7024
commit a48a867
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1356,6 +1356,12 @@ impl<'a, TNpmRegistryApi: NpmRegistryApi> | |
} else { | ||
(None, path) | ||
}; | ||
|
||
if path.is_empty() { | ||
// the peer dep is the same as the parent, so we don't need to do anything | ||
return; | ||
} | ||
|
||
self.add_peer_deps_to_path(path, &[(&peer_dep, peer_dep_nv.clone())]); | ||
|
||
// now set the peer dependency | ||
|
@@ -3904,6 +3910,24 @@ mod test { | |
} | ||
} | ||
|
||
#[tokio::test] | ||
async fn peer_dep_on_self() { | ||
let api = TestNpmRegistryApi::default(); | ||
api.ensure_package_version("package-a", "1.0.0"); | ||
api.add_peer_dependency(("package-a", "1.0.0"), ("package-a", "1")); | ||
|
||
let snapshot = | ||
run_resolver_and_get_snapshot(api, vec!["[email protected]"]).await; | ||
let packages = package_names_with_info( | ||
&snapshot, | ||
&NpmSystemInfo { | ||
os: "darwin".to_string(), | ||
cpu: "x86_64".to_string(), | ||
}, | ||
); | ||
assert_eq!(packages, vec!["[email protected]".to_string()]); | ||
} | ||
|
||
#[tokio::test] | ||
async fn non_existent_optional_peer_dep() { | ||
let api = TestNpmRegistryApi::default(); | ||
|