diff --git a/crates/oxc_resolver/src/cache.rs b/crates/oxc_resolver/src/cache.rs index 116514251..a2d4977a2 100644 --- a/crates/oxc_resolver/src/cache.rs +++ b/crates/oxc_resolver/src/cache.rs @@ -36,7 +36,7 @@ impl Cache { if let Some(result) = self.cache.get(path) { return *result; } - let file_metadata = self.fs.metadata(path).ok(); + let file_metadata = self.fs.symlink_metadata(path).ok(); self.cache.insert(path.to_path_buf().into_boxed_path(), file_metadata); file_metadata } diff --git a/crates/oxc_resolver/src/file_system.rs b/crates/oxc_resolver/src/file_system.rs index 527dfc952..634008f54 100644 --- a/crates/oxc_resolver/src/file_system.rs +++ b/crates/oxc_resolver/src/file_system.rs @@ -8,8 +8,12 @@ pub trait FileSystem: Default + Send + Sync { /// # Errors /// - /// * Any [io::Error] - fn metadata>(&self, path: P) -> io::Result; + /// This function will return an error in the following situations, but is not + /// limited to just these cases: + /// + /// * The user lacks permissions to perform `metadata` call on `path`. + /// * `path` does not exist. + fn symlink_metadata>(&self, path: P) -> io::Result; } #[derive(Debug, Clone, Copy)] @@ -32,7 +36,7 @@ impl FileSystem for FileSystemOs { fs::read_to_string(path) } - fn metadata>(&self, path: P) -> io::Result { - fs::metadata(path).map(|metadata| FileMetadata { is_file: metadata.is_file() }) + fn symlink_metadata>(&self, path: P) -> io::Result { + fs::symlink_metadata(path).map(|metadata| FileMetadata { is_file: metadata.is_file() }) } } diff --git a/crates/oxc_resolver/tests/memory_fs.rs b/crates/oxc_resolver/tests/memory_fs.rs index 8997b2ca7..8b5b917ee 100644 --- a/crates/oxc_resolver/tests/memory_fs.rs +++ b/crates/oxc_resolver/tests/memory_fs.rs @@ -48,7 +48,7 @@ impl FileSystem for MemoryFS { Ok(buffer) } - fn metadata>(&self, path: P) -> io::Result { + fn symlink_metadata>(&self, path: P) -> io::Result { use vfs::FileSystem; let metadata = self .fs