Skip to content

Commit 6b5bd95

Browse files
committed
Fixes tests
1 parent 4963e10 commit 6b5bd95

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/lib.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use radix_trie::Trie;
66
use serde::Deserialize;
77
use serde_with::{serde_as, DefaultOnNull};
88
use simple_error::{self, bail, SimpleError};
9-
use std::{path::{Path, PathBuf, Component}, fs, collections::{HashSet, HashMap}};
9+
use std::{path::{Path, PathBuf, Component}, fs, collections::{HashSet, HashMap, hash_map::Entry}};
1010
use util::RegexDef;
1111

1212
pub enum Resolution {
@@ -231,6 +231,16 @@ pub fn init_pnp_manifest(manifest: &mut Manifest, p: &Path) {
231231
});
232232
}
233233
}
234+
235+
let top_level_pkg = manifest.package_registry_data
236+
.get("").expect("Assertion failed: Should have a top-level name key")
237+
.get("").expect("Assertion failed: Should have a top-level range key");
238+
239+
for (name, dependency) in &top_level_pkg.package_dependencies {
240+
if let Entry::Vacant(entry) = manifest.fallback_pool.entry(name.clone()) {
241+
entry.insert(dependency.clone());
242+
}
243+
}
234244
}
235245

236246
pub fn find_pnp_manifest(parent: &Path) -> Result<Option<Manifest>, Box<dyn std::error::Error>> {
@@ -291,8 +301,8 @@ pub fn resolve_to_unqualified(specifier: &str, parent: &Path, config: &PnpResolu
291301
let mut is_set = false;
292302

293303
if !is_set {
294-
if let Some(binding) = parent_pkg.package_dependencies.get(&ident) {
295-
reference_or_alias = binding.clone();
304+
if let Some(Some(binding)) = parent_pkg.package_dependencies.get(&ident) {
305+
reference_or_alias = Some(binding.clone());
296306
is_set = true;
297307
}
298308
}

src/lib_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ mod tests {
6767
Ok(Resolution::Specifier(specifier)) => {
6868
assert_eq!(specifier, test.expected);
6969
},
70-
Err(_) => {
71-
assert_eq!(test.expected, "error!");
70+
Err(err) => {
71+
assert_eq!(test.expected, "error!", "{}: {}", test.it, err);
7272
},
7373
}
7474

0 commit comments

Comments
 (0)