From 5c1aaebea50a6346752bc36d27c2dd5b43d5feeb Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Wed, 16 Aug 2023 18:41:16 +0200 Subject: [PATCH] Fix unreachable in playground --- crates/ruff/src/fs.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/ruff/src/fs.rs b/crates/ruff/src/fs.rs index c8ff19546821d..2a617113fe2ee 100644 --- a/crates/ruff/src/fs.rs +++ b/crates/ruff/src/fs.rs @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf}; use globset::GlobMatcher; use log::debug; -use path_absolutize::{path_dedot, Absolutize}; +use path_absolutize::Absolutize; use crate::registry::RuleSet; @@ -61,7 +61,13 @@ pub fn normalize_path_to, R: AsRef>(path: P, project_root: /// Convert an absolute path to be relative to the current working directory. pub fn relativize_path>(path: P) -> String { let path = path.as_ref(); - if let Ok(path) = path.strip_prefix(&*path_dedot::CWD) { + + #[cfg(target_arch = "wasm32")] + let cwd = Path::new("."); + #[cfg(not(target_arch = "wasm32"))] + let cwd = path_absolutize::path_dedot::CWD.as_path(); + + if let Ok(path) = path.strip_prefix(cwd) { return format!("{}", path.display()); } format!("{}", path.display())