1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

fix(npm): do not panic hitting root dir while resolving npm package (#23556)

Closes https://github.com/denoland/deno/issues/23029
This commit is contained in:
David Sherret 2024-04-25 10:13:55 -04:00 committed by GitHub
parent 1a5b6296c5
commit bc4aa5f901
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -168,8 +168,8 @@ impl NpmPackageFsResolver for LocalNpmPackageResolver {
};
let package_root_path = self.resolve_package_root(&local_path);
let mut current_folder = package_root_path.as_path();
loop {
current_folder = current_folder.parent().unwrap();
while let Some(parent_folder) = current_folder.parent() {
current_folder = parent_folder;
let node_modules_folder = if current_folder.ends_with("node_modules") {
Cow::Borrowed(current_folder)
} else {
@ -191,13 +191,15 @@ impl NpmPackageFsResolver for LocalNpmPackageResolver {
}
if current_folder == self.root_node_modules_path {
bail!(
"could not find package '{}' from referrer '{}'.",
name,
referrer
);
break;
}
}
bail!(
"could not find package '{}' from referrer '{}'.",
name,
referrer
);
}
fn resolve_package_folder_from_specifier(