fix: peer names in virtual store directory names (#3545)

This commit is contained in:
Zoltan Kochan
2021-06-20 01:58:51 +03:00
committed by GitHub
parent 5950459d7f
commit 060c736779
5 changed files with 15 additions and 11 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/resolve-dependencies": patch
---
Use the real package names of the peer dependencies, when creating the paths in the virtual store.

View File

@@ -228,10 +228,9 @@ function resolvePeersOfNode<T extends PartialResolvedPackage> (
depPath = resolvedPackage.depPath
} else {
const peersFolderSuffix = createPeersFolderSuffix(
Object.keys(allResolvedPeers).map((alias) => ({
name: alias,
version: ctx.dependenciesTree[allResolvedPeers[alias]].resolvedPackage.version,
})))
Object.keys(allResolvedPeers)
.map((alias) => ctx.dependenciesTree[allResolvedPeers[alias]].resolvedPackage)
.map(({ name, version }) => ({ name, version })))
depPath = `${resolvedPackage.depPath}${peersFolderSuffix}`
}
const localLocation = path.join(ctx.virtualStoreDir, depPathToFilename(depPath, ctx.lockfileDir))

View File

@@ -54,8 +54,8 @@ test('resolve peer dependencies of cyclic dependencies', () => {
},
installable: true,
resolvedPackage: {
name: 'zoo',
depPath: 'zoo/1.0.0',
name: 'qar',
depPath: 'qar/1.0.0',
version: '1.0.0',
peerDependencies: {
foo: '1.0.0',
@@ -101,7 +101,7 @@ test('resolve peer dependencies of cyclic dependencies', () => {
'foo/1.0.0_qar@1.0.0+zoo@1.0.0',
'bar/1.0.0_foo@1.0.0+zoo@1.0.0',
'zoo/1.0.0_qar@1.0.0',
'zoo/1.0.0_bar@1.0.0+foo@1.0.0+qar@1.0.0',
'qar/1.0.0_bar@1.0.0+foo@1.0.0',
'bar/1.0.0_foo@1.0.0',
'foo/1.0.0',
])

View File

@@ -120,14 +120,14 @@ test('a subdependency is from a github repo with different name', async () => {
const lockfile = await project.readLockfile()
expect(lockfile.packages['/has-aliased-git-dependency/1.0.0'].dependencies).toStrictEqual({
'has-say-hi-peer': '1.0.0_say-hi@1.0.0',
'has-say-hi-peer': '1.0.0_hi@1.0.0',
'say-hi': 'github.com/zkochan/hi/4cdebec76b7b9d1f6e219e06c42d92a6b8ea60cd',
})
await project.isExecutable('has-aliased-git-dependency/node_modules/.bin/hi')
await project.isExecutable('has-aliased-git-dependency/node_modules/.bin/szia')
expect(await exists(path.resolve('node_modules/.pnpm/has-say-hi-peer@1.0.0_say-hi@1.0.0/node_modules/has-say-hi-peer'))).toBeTruthy()
expect(await exists(path.resolve('node_modules/.pnpm/has-say-hi-peer@1.0.0_hi@1.0.0/node_modules/has-say-hi-peer'))).toBeTruthy()
})
test('from a git repo', async () => {

View File

@@ -755,8 +755,8 @@ test('peer dependency is resolved from parent package via its alias', async () =
const lockfile = await readYamlFile<Lockfile>(WANTED_LOCKFILE)
expect(Object.keys(lockfile.packages ?? {})).toStrictEqual([
'/has-tango-as-peer-dep/1.0.0_tango@1.0.0',
'/tango-tango/1.0.0_tango@1.0.0',
'/has-tango-as-peer-dep/1.0.0_tango-tango@1.0.0',
'/tango-tango/1.0.0_tango-tango@1.0.0',
])
})