Skip to content

Commit 4ac26c3

Browse files
committed
chore: testing on CI
1 parent e19d94a commit 4ac26c3

File tree

3 files changed

+34
-23
lines changed

3 files changed

+34
-23
lines changed

src/lib.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,18 @@ 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!("manifest.manifest_dir, {}", manifest.manifest_dir.to_string_lossy());
161+
160162
let package_location = manifest.manifest_dir.join(info.package_location.clone());
161163

162164
let normalized_location = util::normalize_path(package_location.to_string_lossy());
163165

166+
println!("normalized_location: {normalized_location}");
167+
164168
info.package_location = PathBuf::from(normalized_location);
165169

170+
println!("info.package_location: {}", info.package_location.to_string_lossy());
171+
166172
if !info.discard_from_lookup {
167173
manifest.location_trie.insert(
168174
&info.package_location,
@@ -207,6 +213,12 @@ pub fn find_locator<'a, P: AsRef<Path>>(
207213
}
208214
}
209215

216+
println!("path {}", path.as_ref().to_string_lossy());
217+
218+
let path = util::normalize_path(path.as_ref().to_string_lossy());
219+
220+
println!("path {path}");
221+
210222
manifest.location_trie.get_ancestor_value(&path)
211223
}
212224

@@ -341,10 +353,7 @@ pub fn resolve_to_unqualified_via_manifest<P: AsRef<Path>>(
341353
}
342354
}?;
343355

344-
Ok(Resolution::Resolved(
345-
dependency_pkg.package_location.clone(),
346-
module_path,
347-
))
356+
Ok(Resolution::Resolved(dependency_pkg.package_location.clone(), module_path))
348357
} else {
349358
let broken_ancestors = find_broken_peer_dependencies(specifier, parent_locator);
350359

src/lib_tests.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ mod tests {
2323
use super::*;
2424
use crate::{
2525
ResolutionConfig, ResolutionHost, init_pnp_manifest, load_pnp_manifest,
26-
parse_bare_identifier, resolve_to_unqualified, resolve_to_unqualified_via_manifest,
26+
parse_bare_identifier, resolve_to_unqualified, resolve_to_unqualified_via_manifest, util,
2727
};
2828

2929
#[test]
@@ -167,19 +167,16 @@ mod tests {
167167
#[test]
168168
fn test_global_cache() {
169169
let manifest = load_pnp_manifest(
170-
env::current_dir()
171-
.unwrap()
172-
.join("fixtures")
173-
.join("global-cache")
174-
.join(".pnp.cjs"),
170+
env::current_dir().unwrap().join("fixtures").join("global-cache").join(".pnp.cjs"),
175171
)
176172
.unwrap();
177173

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

184181
let result = resolve_to_unqualified_via_manifest(
185182
&manifest,
@@ -194,12 +191,15 @@ mod tests {
194191
match result {
195192
Ok(Resolution::Resolved(path, subpath)) => {
196193
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("")
194+
path.to_string_lossy(),
195+
util::normalize_path(
196+
global_cache
197+
.join("source-map-npm-0.6.1-1a3621db16-10c0.zip")
198+
.join("node_modules")
199+
.join("source-map")
200+
.join("")
201+
.to_string_lossy()
202+
)
203203
);
204204
assert_eq!(subpath, None);
205205
}

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::{MAIN_SEPARATOR_STR, Path, PathBuf};
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)