Skip to content

Commit 02cf29b

Browse files
committed
Adds an helper
1 parent b875af9 commit 02cf29b

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pnp"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
edition = "2021"
55
license = "BSD-2-Clause"
66
description = "Resolution primitives for Yarn PnP"

src/fs.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ pub enum VPath {
2121
Native(PathBuf),
2222
}
2323

24+
impl VPath {
25+
pub fn physical_path(&self) -> PathBuf {
26+
match &self {
27+
VPath::Virtual(VPathInfo { base_path, virtual_segments: None, .. })
28+
=> PathBuf::from(base_path),
29+
VPath::Virtual(VPathInfo { base_path, virtual_segments: Some((_virtual_segment, physical_segment)), .. })
30+
=> PathBuf::from(base_path).join(physical_segment),
31+
VPath::Native(p)
32+
=> p.clone(),
33+
}
34+
}
35+
}
36+
2437
#[derive(thiserror::Error, Debug)]
2538
pub enum Error {
2639
#[error("Entry not found")]

0 commit comments

Comments
 (0)