Skip to content
This repository has been archived by the owner on May 14, 2018. It is now read-only.

Commit

Permalink
fix: log the correct number of added packages
Browse files Browse the repository at this point in the history
  • Loading branch information
zkochan committed Dec 26, 2017
1 parent baf1938 commit 0b31c04
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/link/index.ts
Expand Up @@ -205,7 +205,8 @@ async function linkNewPackages (
const prevPkgResolvedIds = R.keys(currentShrinkwrap.packages)

// TODO: what if the registries differ?
const newPkgResolvedIds = (
const newPkgResolvedIdsSet = new Set(
(
opts.force
? nextPkgResolvedIds
: R.difference(nextPkgResolvedIds, prevPkgResolvedIds)
Expand All @@ -214,8 +215,7 @@ async function linkNewPackages (
// when installing a new package, not all the nodes are analyzed
// just skip the ones that are in the lockfile but were not analyzed
.filter(resolvedId => pkgsToLink[resolvedId])

const newPkgs = R.props<string, DependencyTreeNode>(newPkgResolvedIds, pkgsToLink)
)

if (!opts.force && currentShrinkwrap.packages && wantedShrinkwrap.packages) {
// add subdependencies that have been updated
Expand All @@ -229,13 +229,16 @@ async function linkNewPackages (
// TODO: come up with a test that triggers the usecase of pkgsToLink[resolvedId] undefined
// see related issue: https://github.com/pnpm/pnpm/issues/870
if (pkgsToLink[resolvedId]) {
newPkgs.push(pkgsToLink[resolvedId])
newPkgResolvedIdsSet.add(resolvedId)
}
}
}
}

if (!newPkgs.length) return []
if (!newPkgResolvedIdsSet.size) return []

const newPkgResolvedIds = Array.from(newPkgResolvedIdsSet)
const newPkgs = R.props<string, DependencyTreeNode>(newPkgResolvedIds, pkgsToLink)

logger.info(`Adding ${newPkgs.length} packages to node_modules`)

Expand Down

0 comments on commit 0b31c04

Please sign in to comment.