Skip to content

Commit 1d13b10

Browse files
committed
Fixes tidbits
1 parent 9479357 commit 1d13b10

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

fixtures/global-cache/.yarnrc.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
enableGlobalCache: true
22

3-
globalFolder: "D:\\yarn-global"
4-
53
nodeLinker: pnp

src/util.rs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,43 +33,36 @@ impl<T> Trie<T> {
3333
}
3434

3535
pub fn normalize_path<P: AsRef<str>>(original: P) -> String {
36-
let original_str
37-
= original.as_ref();
36+
let original_str = original.as_ref();
3837

39-
let check_str_root
40-
= original_str.strip_prefix("/");
41-
let str_minus_root
42-
= check_str_root.unwrap_or(original_str);
38+
let check_str_root = original_str.strip_prefix("/");
39+
let str_minus_root = check_str_root.unwrap_or(original_str);
4340

44-
let components
45-
= str_minus_root.split(&['/', '\\'][..]);
41+
let components = str_minus_root.split(&['/', '\\'][..]);
4642

47-
let mut out: Vec<&str>
48-
= Vec::new();
43+
let mut out: Vec<&str> = Vec::new();
4944

5045
for comp in components {
5146
match comp {
5247
"" | "." => {
5348
// Those components don't progress the path
54-
},
49+
}
5550

5651
".." => match out.last() {
5752
None if check_str_root.is_some() => {
5853
// No need to add a ".." since we're already at the root
59-
},
54+
}
6055

6156
Some(&"..") | None => {
6257
out.push(comp);
63-
},
58+
}
6459

6560
Some(_) => {
6661
out.pop();
67-
},
62+
}
6863
},
6964

70-
comp => {
71-
out.push(comp)
72-
},
65+
comp => out.push(comp),
7366
}
7467
}
7568

@@ -81,8 +74,7 @@ pub fn normalize_path<P: AsRef<str>>(original: P) -> String {
8174
}
8275
}
8376

84-
let mut str
85-
= out.join("/");
77+
let mut str = out.join("/");
8678

8779
if out.is_empty() {
8880
return ".".to_string();
@@ -94,6 +86,9 @@ pub fn normalize_path<P: AsRef<str>>(original: P) -> String {
9486
str.push('/');
9587
}
9688

89+
println!("{}", original_str);
90+
println!("-> {}", str);
91+
9792
str
9893
}
9994

0 commit comments

Comments
 (0)