Skip to content

Commit 060219f

Browse files
committed
chore: testing on CI
1 parent e19d94a commit 060219f

File tree

3 files changed

+38
-15
lines changed

3 files changed

+38
-15
lines changed

src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,24 @@ pub fn init_pnp_manifest<P: AsRef<Path>>(manifest: &mut Manifest, p: P) {
157157

158158
for (name, ranges) in manifest.package_registry_data.iter_mut() {
159159
for (reference, info) in ranges.iter_mut() {
160+
println!(
161+
"manifest.manifest_dir, {}",
162+
manifest.manifest_dir.to_string_lossy()
163+
);
164+
160165
let package_location = manifest.manifest_dir.join(info.package_location.clone());
161166

162167
let normalized_location = util::normalize_path(package_location.to_string_lossy());
163168

169+
println!("normalized_location: {}", normalized_location);
170+
164171
info.package_location = PathBuf::from(normalized_location);
165172

173+
println!(
174+
"info.package_location: {}",
175+
info.package_location.to_string_lossy()
176+
);
177+
166178
if !info.discard_from_lookup {
167179
manifest.location_trie.insert(
168180
&info.package_location,
@@ -207,6 +219,12 @@ pub fn find_locator<'a, P: AsRef<Path>>(
207219
}
208220
}
209221

222+
println!("path {}", path.as_ref().to_string_lossy());
223+
224+
let path = util::normalize_path(path.as_ref().to_string_lossy());
225+
226+
println!("path {}", path);
227+
210228
manifest.location_trie.get_ancestor_value(&path)
211229
}
212230

src/lib_tests.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ mod tests {
2222

2323
use super::*;
2424
use crate::{
25-
ResolutionConfig, ResolutionHost, init_pnp_manifest, load_pnp_manifest,
26-
parse_bare_identifier, resolve_to_unqualified, resolve_to_unqualified_via_manifest,
25+
init_pnp_manifest, load_pnp_manifest, parse_bare_identifier, resolve_to_unqualified, resolve_to_unqualified_via_manifest, util, ResolutionConfig, ResolutionHost
2726
};
2827

2928
#[test]
@@ -175,11 +174,12 @@ mod tests {
175174
)
176175
.unwrap();
177176

178-
let global_cache = dirs::home_dir()
179-
.unwrap()
180-
.join(".yarn")
181-
.join("berry")
182-
.join("cache");
177+
let home_dir = dirs::home_dir().unwrap();
178+
179+
#[cfg(windows)]
180+
let global_cache = home_dir.join("AppData\\Local\\Yarn\\Berry");
181+
#[cfg(not(windows))]
182+
let global_cache = home_dir.join(".yarn/berry/cache");
183183

184184
let result = resolve_to_unqualified_via_manifest(
185185
&manifest,
@@ -194,12 +194,15 @@ mod tests {
194194
match result {
195195
Ok(Resolution::Resolved(path, subpath)) => {
196196
assert_eq!(
197-
path,
198-
global_cache
199-
.join("source-map-npm-0.6.1-1a3621db16-10c0.zip")
200-
.join("node_modules")
201-
.join("source-map")
202-
.join("")
197+
path.to_string_lossy(),
198+
util::normalize_path(
199+
global_cache
200+
.join("source-map-npm-0.6.1-1a3621db16-10c0.zip")
201+
.join("node_modules")
202+
.join("source-map")
203+
.join("")
204+
.to_string_lossy()
205+
)
203206
);
204207
assert_eq!(subpath, None);
205208
}

src/util.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use serde::{Deserialize, Deserializer, de::Error};
33
use std::borrow::Cow;
44

55
use path_slash::PathBufExt;
6-
use std::path::{Path, PathBuf};
6+
use std::path::{Path, PathBuf, MAIN_SEPARATOR_STR};
77

88
#[derive(Debug, Default, Clone)]
99
pub struct Trie<T> {
@@ -39,7 +39,9 @@ pub fn normalize_path<P: AsRef<str>>(original: P) -> String {
3939
let p = PathBuf::from(original_str);
4040
let mut str = clean_path::clean(p).to_slash_lossy().to_string();
4141

42-
if original_str.ends_with('/') && !str.ends_with('/') {
42+
if (original_str.ends_with('/') || original_str.ends_with(MAIN_SEPARATOR_STR))
43+
&& !str.ends_with('/')
44+
{
4345
str.push('/');
4446
}
4547

0 commit comments

Comments
 (0)