Skip to content

Commit 89356d8

Browse files
authored
fix(deno_facade): should not assume that all module paths to be extracted have the same prefix (#639)
1 parent 3dbd647 commit 89356d8

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

crates/deno_facade/lib.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,10 @@ async fn create_module_path(
5050
output_folder: &Path,
5151
) -> PathBuf {
5252
let cleaned_specifier = strip_file_scheme(global_specifier);
53-
let cleaned_specifier =
54-
cleaned_specifier.replace(entry_path.to_str().unwrap(), "");
55-
let module_path = PathBuf::from(cleaned_specifier);
53+
let cleaned_path =
54+
pathdiff::diff_paths(&*cleaned_specifier, entry_path).unwrap();
5655

57-
if let Some(parent) = module_path.parent() {
56+
if let Some(parent) = cleaned_path.parent() {
5857
if parent.parent().is_some() {
5958
let output_folder_and_mod_folder = output_folder.join(
6059
parent
@@ -68,9 +67,9 @@ async fn create_module_path(
6867
}
6968

7069
output_folder.join(
71-
module_path
70+
cleaned_path
7271
.strip_prefix("/")
73-
.unwrap_or_else(|_| ensure_unix_relative_path(&module_path)),
72+
.unwrap_or_else(|_| ensure_unix_relative_path(&cleaned_path)),
7473
)
7574
}
7675

0 commit comments

Comments
 (0)