Skip to content

Commit

Permalink
fix: a file dep has a file dep
Browse files Browse the repository at this point in the history
close #4611
  • Loading branch information
zkochan committed Apr 24, 2022
1 parent 22ab407 commit 525975f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
37 changes: 36 additions & 1 deletion packages/core/test/install/local.ts
@@ -1,7 +1,7 @@
import { promises as fs } from 'fs'
import path from 'path'
import { LOCKFILE_VERSION } from '@pnpm/constants'
import { prepareEmpty } from '@pnpm/prepare'
import { prepareEmpty, preparePackages } from '@pnpm/prepare'
import { addDistTag } from '@pnpm/registry-mock'
import fixtures from '@pnpm/test-fixtures'
import {
Expand Down Expand Up @@ -239,3 +239,38 @@ test('frozen-lockfile: installation fails if the integrity of a tarball dependen
install(manifest, await testDefaults({ frozenLockfile: true }))
).rejects.toThrow(/Got unexpected checksum/)
})

test('deep local', async () => {
const manifest1 = {
name: 'project-1',
version: '1.0.0',
dependencies: {
'project-2': 'file:../project-2',
},
}
preparePackages([
{
location: 'project-1',
package: manifest1,
},
{
location: 'project-2',
package: {
name: 'project-2',
version: '1.0.0',
dependencies: {
'project-3': 'file:./project-3',
},
},
},
{
location: 'project-2/project-3',
package: {
name: 'project-3',
version: '1.0.0',
},
},
])
process.chdir('../project-1')
await install(manifest1, await testDefaults())
})
9 changes: 8 additions & 1 deletion packages/resolve-dependencies/src/resolveDependencies.ts
Expand Up @@ -159,6 +159,7 @@ export type PkgAddress = {
pkg: PackageManifest
version?: string
updated: boolean
prefix: string
} & ({
isLinkedDependency: true
version: string
Expand Down Expand Up @@ -320,7 +321,10 @@ async function resolveDependenciesOfDependency (

postponedResolutionsQueue.push(async (preferredVersions) =>
resolveChildren(
ctx,
{
...ctx,
prefix: resolveDependencyResult.prefix,
},
resolveDependencyResult,
extendedWantedDep.infoFromLockfile?.dependencyLockfile,
options.workspacePackages,
Expand Down Expand Up @@ -831,6 +835,9 @@ async function resolveDependency (
nodeId,
normalizedPref: options.currentDepth === 0 ? pkgResponse.body.normalizedPref : undefined,
pkgId: pkgResponse.body.id,
prefix: pkgResponse.body.resolution.type === 'directory'
? path.resolve(ctx.prefix, pkgResponse.body.resolution['directory'])
: ctx.prefix,

// Next fields are actually only needed when isNew = true
installable,
Expand Down

0 comments on commit 525975f

Please sign in to comment.