feat: print more info on different stages of installation

This commit is contained in:
zkochan
2017-07-01 14:32:46 +03:00
parent 00316c90c0
commit e1476af76e
2 changed files with 19 additions and 9 deletions

View File

@@ -8,6 +8,7 @@ import {read as readStore, save as saveStore} from '../fs/storeController'
import R = require('ramda')
import {PackageSpec} from '../resolve'
import removeTopDependency from '../removeTopDependency'
import logger from 'pnpm-logger'
export default async function removeOrphanPkgs (
oldShr: Shrinkwrap,
@@ -29,16 +30,20 @@ export default async function removeOrphanPkgs (
const store = await readStore(storePath) || {}
const notDependents = R.difference(oldPkgIds, newPkgIds)
await Promise.all(Array.from(notDependents).map(async notDependent => {
if (store[notDependent]) {
store[notDependent].splice(store[notDependent].indexOf(root), 1)
if (!store[notDependent].length) {
delete store[notDependent]
await rimraf(path.join(storePath, notDependent))
if (notDependents.length) {
logger.info(`Removing ${notDependents.length} orphan packages from node_modules`);
await Promise.all(notDependents.map(async notDependent => {
if (store[notDependent]) {
store[notDependent].splice(store[notDependent].indexOf(root), 1)
if (!store[notDependent].length) {
delete store[notDependent]
await rimraf(path.join(storePath, notDependent))
}
}
}
await rimraf(path.join(rootModules, `.${notDependent}`))
}))
await rimraf(path.join(rootModules, `.${notDependent}`))
}))
}
const newDependents = R.difference(newPkgIds, oldPkgIds)

View File

@@ -48,6 +48,7 @@ export default async function (
newPkgResolvedIds: string[],
}> {
const topPkgIds = topPkgs.map(pkg => pkg.id)
logger.info(`Creating dependency tree`)
const pkgsToLink = await resolvePeers(tree, rootNodeIds, topPkgIds, opts.topParents, opts.independentLeaves)
const newShr = updateShrinkwrap(pkgsToLink, opts.shrinkwrap, opts.pkg)
@@ -152,6 +153,10 @@ async function linkNewPackages (
}
}
if (!newPkgs.length) return []
logger.info(`Adding ${newPkgs.length} packages to node_modules`)
await Promise.all([
linkAllModules(newPkgs, pkgsToLink, {optional: opts.optional}),
(async () => {