Skip to content

Commit 93d9ffe

Browse files
committed
Use pathdiff for vp path remapping
1 parent 661ef64 commit 93d9ffe

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ os_str_bytes = "7.1.1"
9090
ouroboros = "0.18.5"
9191
owo-colors = "4.1.0"
9292
passfd = { git = "https://github.com/polachok/passfd", rev = "d55881752c16aced1a49a75f9c428d38d3767213", default-features = false }
93+
pathdiff = "0.2.3"
9394
petgraph = "0.8.2"
9495
phf = { version = "0.11.3", features = ["macros"] }
9596
portable-pty = "0.9.0"

crates/vite_task_bin/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ which = { workspace = true }
2929
cow-utils = { workspace = true }
3030
cp_r = { workspace = true }
3131
insta = { workspace = true, features = ["glob", "json", "redactions", "filters", "ron"] }
32+
pathdiff = { workspace = true }
3233
pty_terminal = { workspace = true }
3334
pty_terminal_test = { workspace = true }
3435
regex = { workspace = true }

crates/vite_task_bin/tests/e2e_snapshots/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::{
99
};
1010

1111
use cp_r::CopyOptions;
12+
use pathdiff::diff_paths;
1213
use pty_terminal::{geo::ScreenSize, terminal::CommandBuilder};
1314
use pty_terminal_test::TestTerminal;
1415
use redact::redact_e2e_output;
@@ -68,14 +69,14 @@ fn resolve_runtime_vp_path() -> AbsolutePathBuf {
6869
let compile_time_repo_root = compile_time_manifest.parent().unwrap().parent().unwrap();
6970
let runtime_repo_root = runtime_manifest.parent().unwrap().parent().unwrap();
7071

71-
let relative_vp = compile_time_vp.strip_prefix(compile_time_repo_root).unwrap_or_else(|_| {
72+
let relative_vp = diff_paths(&compile_time_vp, compile_time_repo_root).unwrap_or_else(|| {
7273
panic!(
73-
"Failed to resolve vp relative path. vp={} repo_root={}",
74+
"Failed to diff vp path. vp={} repo_root={}",
7475
compile_time_vp.display(),
7576
compile_time_repo_root.display(),
7677
)
7778
});
78-
let runtime_vp = runtime_repo_root.join(relative_vp);
79+
let runtime_vp = runtime_repo_root.join(&relative_vp);
7980

8081
assert!(
8182
runtime_vp.exists(),

0 commit comments

Comments
 (0)