Skip to content

Commit

Permalink
refactor: no additional nesting when peer resolved from own dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed May 18, 2017
1 parent cc21a4e commit e95ae02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/link/resolvePeers.ts
Expand Up @@ -154,7 +154,7 @@ function resolvePeersOfNode (
unknownResolvedPeersOfChildren.push.apply(unknownResolvedPeersOfChildren, unknownResolvedPeersOfChild)
}

const resolvedPeers = resolvePeers(node.pkg.peerDependencies, node.pkg.id, newParentPkgs)
const resolvedPeers = resolvePeers(node.pkg.peerDependencies, node.pkg.id, parentPkgs)
const allResolvedPeers = R.uniq(unknownResolvedPeersOfChildren.concat(resolvedPeers))

const modules = !R.isEmpty(allResolvedPeers)
Expand Down
8 changes: 7 additions & 1 deletion test/install/peerDependencies.ts
Expand Up @@ -139,8 +139,14 @@ test('run pre/postinstall scripts of each variations of packages with peer depen
})

test('package that resolves its own peer dependency', async (t: tape.Test) => {
// TODO: investigate how npm behaves in such situations
// should there be a warning printed?
// does it currently print a warning that peer dependency is not resolved?

const project = prepare(t)
await installPkgs(['pkg-with-resolved-peer', 'peer-c@2.0.0'], testDefaults())

t.ok(await exists(path.join(NM, '.localhost+4873', 'pkg-with-resolved-peer', '1.0.0', 'peer-c@1.0.0', NM, 'pkg-with-resolved-peer')))
t.equal(deepRequireCwd(['pkg-with-resolved-peer', 'peer-c', './package.json']).version, '1.0.0')

t.ok(await exists(path.join(NM, '.localhost+4873', 'pkg-with-resolved-peer', '1.0.0', NM, 'pkg-with-resolved-peer')))
})

0 comments on commit e95ae02

Please sign in to comment.