From 2f651b2d64523bdd377d22b8b7213a04ad82f459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 2 May 2023 02:35:33 +0200 Subject: fix(npm): canonicalize filename before returning (#18948) This commit changes how paths for npm packages are handled, by canonicalizing them when resolving. This is done so that instead of returning "node_modules/@/node_modules//index.js" (which is a symlink) we "node_modules/@/index.js. Fixes https://github.com/denoland/deno/issues/18924 Fixes https://github.com/bluwy/create-vite-extra/issues/31 --------- Co-authored-by: David Sherret --- runtime/fs_util.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'runtime') diff --git a/runtime/fs_util.rs b/runtime/fs_util.rs index a29a57b39..eb4a2f899 100644 --- a/runtime/fs_util.rs +++ b/runtime/fs_util.rs @@ -10,16 +10,7 @@ use std::path::PathBuf; /// Similar to `std::fs::canonicalize()` but strips UNC prefixes on Windows. pub fn canonicalize_path(path: &Path) -> Result { - let mut canonicalized_path = path.canonicalize()?; - if cfg!(windows) { - canonicalized_path = PathBuf::from( - canonicalized_path - .display() - .to_string() - .trim_start_matches("\\\\?\\"), - ); - } - Ok(canonicalized_path) + Ok(deno_core::strip_unc_prefix(path.canonicalize()?)) } #[inline] -- cgit v1.2.3