Skip to content

Commit 9094b7d

Browse files
committed
Moves the helper to a more coherent location
1 parent 02cf29b commit 9094b7d

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
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.1"
3+
version = "0.5.2"
44
edition = "2021"
55
license = "BSD-2-Clause"
66
description = "Resolution primitives for Yarn PnP"

src/fs.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ pub struct VPathInfo {
1313
pub zip_path: Option<String>,
1414
}
1515

16+
impl VPathInfo {
17+
pub fn physical_base_path(&self) -> PathBuf {
18+
match &self.virtual_segments {
19+
None => PathBuf::from(&self.base_path),
20+
Some(segments) => PathBuf::from(&self.base_path).join(&segments.1),
21+
}
22+
}
23+
}
1624

1725
#[derive(Clone, Debug, Deserialize, PartialEq)]
1826
#[serde(untagged)]
@@ -21,19 +29,6 @@ pub enum VPath {
2129
Native(PathBuf),
2230
}
2331

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-
3732
#[derive(thiserror::Error, Debug)]
3833
pub enum Error {
3934
#[error("Entry not found")]

0 commit comments

Comments
 (0)