mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(resolver): do not search for package.json inside non-existing directories (#1482)
This commit is contained in:
parent
c762a85fcc
commit
abde1e06b0
1 changed files with 4 additions and 9 deletions
|
|
@ -242,17 +242,12 @@ impl CachedPathImpl {
|
|||
options: &ResolveOptions,
|
||||
) -> Result<Option<Arc<PackageJson>>, ResolveError> {
|
||||
let mut cache_value = self;
|
||||
// Go up a directory when querying a file, this avoids a file read from example.js/package.json
|
||||
if cache_value.is_file(fs) {
|
||||
// Go up directories when the querying path is not a directory
|
||||
while !cache_value.is_dir(fs) {
|
||||
if let Some(cv) = &cache_value.parent {
|
||||
cache_value = cv.as_ref();
|
||||
}
|
||||
} else {
|
||||
// Go up a directory when the querying path is neither a file nor a directory
|
||||
if !cache_value.is_dir(fs) {
|
||||
if let Some(cv) = &cache_value.parent {
|
||||
cache_value = cv.as_ref();
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let mut cache_value = Some(cache_value);
|
||||
|
|
|
|||
Loading…
Reference in a new issue