mirror of
https://github.com/denoland/deno
synced 2024-08-28 12:29:31 +00: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:
parent
1a5b6296c5
commit
bc4aa5f901
|
@ -168,8 +168,8 @@ impl NpmPackageFsResolver for LocalNpmPackageResolver {
|
||||||
};
|
};
|
||||||
let package_root_path = self.resolve_package_root(&local_path);
|
let package_root_path = self.resolve_package_root(&local_path);
|
||||||
let mut current_folder = package_root_path.as_path();
|
let mut current_folder = package_root_path.as_path();
|
||||||
loop {
|
while let Some(parent_folder) = current_folder.parent() {
|
||||||
current_folder = current_folder.parent().unwrap();
|
current_folder = parent_folder;
|
||||||
let node_modules_folder = if current_folder.ends_with("node_modules") {
|
let node_modules_folder = if current_folder.ends_with("node_modules") {
|
||||||
Cow::Borrowed(current_folder)
|
Cow::Borrowed(current_folder)
|
||||||
} else {
|
} else {
|
||||||
|
@ -191,13 +191,15 @@ impl NpmPackageFsResolver for LocalNpmPackageResolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
if current_folder == self.root_node_modules_path {
|
if current_folder == self.root_node_modules_path {
|
||||||
bail!(
|
break;
|
||||||
"could not find package '{}' from referrer '{}'.",
|
|
||||||
name,
|
|
||||||
referrer
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bail!(
|
||||||
|
"could not find package '{}' from referrer '{}'.",
|
||||||
|
name,
|
||||||
|
referrer
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_package_folder_from_specifier(
|
fn resolve_package_folder_from_specifier(
|
||||||
|
|
Loading…
Reference in a new issue