fix: uninstall should remove dependency from any property

This commit is contained in:
zkochan
2017-06-26 22:36:36 +03:00
parent 03264e5557
commit 8ca612477d
5 changed files with 13 additions and 24 deletions

View File

@@ -46,14 +46,6 @@ export async function uninstallInContext (pkgsToUninstall: string[], ctx: PnpmCo
const pkgJsonPath = path.join(ctx.root, 'package.json')
const saveType = getSaveType(opts)
const pkg = await removeDeps(pkgJsonPath, pkgsToUninstall, saveType)
if (ctx.shrinkwrap.dependencies) {
for (let depName in ctx.shrinkwrap.dependencies) {
if (!isDependentOn(pkg, depName)) {
delete ctx.shrinkwrap.dependencies[depName]
delete ctx.shrinkwrap.specifiers[depName]
}
}
}
const newShr = await pruneShrinkwrap(ctx.shrinkwrap, pkg)
const removedPkgIds = await removeOrphanPkgs(ctx.privateShrinkwrap, newShr, ctx.root, ctx.storePath)
await saveShrinkwrap(ctx.root, newShr)
@@ -67,15 +59,6 @@ export async function uninstallInContext (pkgsToUninstall: string[], ctx: PnpmCo
await removeOuterLinks(pkgsToUninstall, path.join(ctx.root, 'node_modules'), {storePath: ctx.storePath})
}
function isDependentOn (pkg: Package, depName: string): boolean {
return [
'dependencies',
'devDependencies',
'optionalDependencies',
]
.some(deptype => pkg[deptype] && pkg[deptype][depName])
}
async function removeOuterLinks (
pkgsToUninstall: string[],
modules: string,