Skip to content

Commit

Permalink
fix: pnpm add @teambit/bit should succeed (#4813)
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed May 28, 2022
1 parent a52bf43 commit 06696f8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/wet-needles-remain.md
@@ -0,0 +1,6 @@
---
"@pnpm/resolve-dependencies": patch
"pnpm": patch
---

Correctly detect repeated dependency sequence during resolution.
27 changes: 27 additions & 0 deletions packages/core/test/install/deepRecursive.ts
@@ -0,0 +1,27 @@
import { prepareEmpty } from '@pnpm/prepare'
import { addDependenciesToPackage } from '@pnpm/core'
import isCI from 'is-ci'
import exists from 'path-exists'
import { testDefaults } from '../utils'

const testSkipOnCI = isCI ? test.skip : test

// Looks like GitHub Actions have reduced memory limit for Node.js,
// so it fails in CI at the moment.
testSkipOnCI('a package with a huge amount of circular dependencies and many peer dependencies should successfully be resolved', async () => {
prepareEmpty()

await addDependenciesToPackage({},
['@teambit/bit@0.0.745'],
await testDefaults({
fastUnpack: true,
lockfileOnly: true,
registries: {
'@teambit': 'https://node.bit.dev/',
},
strictPeerDependencies: false,
})
)

expect(await exists('pnpm-lock.yaml')).toBeTruthy()
})
4 changes: 2 additions & 2 deletions packages/resolve-dependencies/src/nodeIdUtils.ts
Expand Up @@ -3,8 +3,8 @@ export function nodeIdContainsSequence (nodeId: string, pkgId1: string, pkgId2:
pkgIds.pop()
const pkg1Index = pkgIds.indexOf(pkgId1)
if (pkg1Index === -1) return false
const pkg2Index = pkgIds.indexOf(pkgId2)
return pkg2Index > -1 && pkg1Index < pkg2Index
const pkg2Index = pkgIds.lastIndexOf(pkgId2)
return pkg1Index < pkg2Index
}

export function createNodeId (parentNodeId: string, pkgId: string) {
Expand Down
5 changes: 5 additions & 0 deletions packages/resolve-dependencies/test/nodeIdUtils.test.ts
@@ -0,0 +1,5 @@
import { nodeIdContainsSequence } from '../lib/nodeIdUtils'

test('nodeIdContainsSequence()', () => {
expect(nodeIdContainsSequence('>.>b>a>c>b>a>', 'a', 'b')).toBeTruthy()
})

0 comments on commit 06696f8

Please sign in to comment.