Skip to content

Commit ac0f94a

Browse files
authored
fix: pnp global cache should be supported (#129)
Windows global cache is still unsupported due to upstream see also yarnpkg/pnp-rs#10
1 parent a184e05 commit ac0f94a

File tree

14 files changed

+166
-14
lines changed

14 files changed

+166
-14
lines changed

.github/actions/pnpm/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,7 @@ runs:
3232
shell: bash
3333
run: |
3434
cd fixtures/pnp
35-
corepack enable
35+
yarn install
36+
37+
cd ../global-pnp
3638
yarn install

Cargo.lock

Lines changed: 58 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ document-features = { version = "0.2.11", optional = true }
8484

8585
[dev-dependencies]
8686
criterion2 = { version = "3.0.0", default-features = false }
87+
dirs = { version = "6.0.0" }
8788
normalize-path = { version = "0.2.1" }
8889
rayon = { version = "1.10.0" }
8990
vfs = "0.12.1" # for testing with in memory file system

benches/resolver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn bench_resolver(c: &mut Criterion) {
148148

149149
// check validity
150150
for (path, request) in &data {
151-
assert!(unrs_resolver().resolve(path, request).is_ok(), "{path:?} {request}");
151+
assert!(unrs_resolver().resolve(path, request).is_ok(), "{:?} {request}", path.display());
152152
}
153153

154154
let symlink_test_dir = create_symlinks().expect("Create symlink fixtures failed");

examples/resolver.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ use unrs_resolver::{AliasValue, ResolveOptions, Resolver};
77
fn main() {
88
let path = PathBuf::from(env::args().nth(1).expect("path"));
99

10-
assert!(path.is_dir(), "{path:?} must be a directory that will be resolved against.");
11-
assert!(path.is_absolute(), "{path:?} must be an absolute path.");
10+
assert!(path.is_dir(), "{} must be a directory that will be resolved against.", path.display());
11+
assert!(path.is_absolute(), "{} must be an absolute path.", path.display());
1212

1313
let specifier = env::args().nth(2).expect("specifier");
1414

15-
println!("path: {path:?}");
15+
println!("path: {}", path.to_string_lossy());
1616
println!("specifier: {specifier}");
1717

1818
let options = ResolveOptions {
@@ -29,6 +29,6 @@ fn main() {
2929

3030
match Resolver::new(options).resolve(path, &specifier) {
3131
Err(error) => println!("Error: {error}"),
32-
Ok(resolution) => println!("Resolved: {:?}", resolution.full_path()),
32+
Ok(resolution) => println!("Resolved: {}", resolution.full_path().display()),
3333
}
3434
}

fixtures/global-pnp/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.pnp.*
2+
.yarn/*
3+
!.yarn/patches
4+
!.yarn/plugins
5+
!.yarn/releases
6+
!.yarn/sdks
7+
!.yarn/versions

fixtures/global-pnp/.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
enableGlobalCache: true

fixtures/global-pnp/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "global-pnp",
3+
"packageManager": "[email protected]",
4+
"dependencies": {
5+
"source-map-support": "^0.5.21"
6+
}
7+
}

fixtures/global-pnp/test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log(require.resolve('source-map-support'))

fixtures/global-pnp/yarn.lock

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This file is generated by running "yarn install" inside your project.
2+
# Manual changes might be lost - proceed with caution!
3+
4+
__metadata:
5+
version: 8
6+
cacheKey: 10c0
7+
8+
"buffer-from@npm:^1.0.0":
9+
version: 1.1.2
10+
resolution: "buffer-from@npm:1.1.2"
11+
checksum: 10c0/124fff9d66d691a86d3b062eff4663fe437a9d9ee4b47b1b9e97f5a5d14f6d5399345db80f796827be7c95e70a8e765dd404b7c3ff3b3324f98e9b0c8826cc34
12+
languageName: node
13+
linkType: hard
14+
15+
"global-pnp@workspace:.":
16+
version: 0.0.0-use.local
17+
resolution: "global-pnp@workspace:."
18+
dependencies:
19+
source-map-support: "npm:^0.5.21"
20+
languageName: unknown
21+
linkType: soft
22+
23+
"source-map-support@npm:^0.5.21":
24+
version: 0.5.21
25+
resolution: "source-map-support@npm:0.5.21"
26+
dependencies:
27+
buffer-from: "npm:^1.0.0"
28+
source-map: "npm:^0.6.0"
29+
checksum: 10c0/9ee09942f415e0f721d6daad3917ec1516af746a8120bba7bb56278707a37f1eb8642bde456e98454b8a885023af81a16e646869975f06afc1a711fb90484e7d
30+
languageName: node
31+
linkType: hard
32+
33+
"source-map@npm:^0.6.0":
34+
version: 0.6.1
35+
resolution: "source-map@npm:0.6.1"
36+
checksum: 10c0/ab55398007c5e5532957cb0beee2368529618ac0ab372d789806f5718123cc4367d57de3904b4e6a4170eb5a0b0f41373066d02ca0735a0c4d75c7d328d3e011
37+
languageName: node
38+
linkType: hard

0 commit comments

Comments
 (0)