hunk.code_window: ): DependencyShrinkwrap {
     const shrResolution = toShrResolution(opts.shortId, opts.resolution)
     const newResolvedDeps = updateResolvedDeps(opts.prevResolvedDeps, opts.updatedDeps, opts.registry, opts.pkgsToLink)
     if (R.isEmpty(newResolvedDeps) &&
       typeof shrResolution === 'string' && !opts.dev && !opts.optional) {
       return shrResolution
     }
     const result = {
       resolution: shrResolution
     }
  
hunk.labels: keep keep keep keep replace keep keep keep keep keep
hunk.after_edit:     typeof shrResolution === 'string' &&
       !opts.dev && !opts.optional && opts.resolvedId === opts.id) {
  
hunk.file_path: src/link/updateShrinkwrap.ts
hunk.type: replace
file: import path = require('path')
  import R = require('ramda')
  import getContext from './getContext'
  import {PnpmOptions, Package} from '../types'
  import extendOptions from './extendOptions'
  import getPkgDirs from '../fs/getPkgDirs'
  import {fromDir as readPkgFromDir} from '../fs/readPkg'
  import lock from './lock'
  import removeOrphanPkgs from './removeOrphanPkgs'
  import {PackageSpec} from '../resolve'
  import {
    ResolvedDependencies,
    prune as pruneShrinkwrap,
  } from '../fs/shrinkwrap'
  
  export async function prune(maybeOpts?: PnpmOptions): Promise<void> {
    const opts = extendOptions(maybeOpts)
  
    const ctx = await getContext(opts)
  
    if (opts.lock === false) {
      return run()
    }
  
    return lock(ctx.storePath, run, {stale: opts.lockStaleDuration})
  
    async function run () {
      if (!ctx.pkg) {
        throw new Error('No package.json found - cannot prune')
      }
  
      const pkg = ctx.pkg
  
      const extraneousPkgs = await getExtraneousPkgs(pkg, ctx.root, opts.production)
  
      const newShr = ctx.shrinkwrap
      extraneousPkgs.forEach(depName => {
        delete newShr.packages['/'].dependencies[depName]
        delete newShr.specifiers[depName]
      })
  
      const prunedShr = pruneShrinkwrap(newShr)
  
      await removeOrphanPkgs(ctx.privateShrinkwrap, prunedShr, ctx.root, ctx.storePath)
    }
  }
  
  async function getExtraneousPkgs (pkg: Package, root: string, production: boolean) {
    const saveTypes = getSaveTypes(production)
    const savedDepsMap = saveTypes.reduce((allDeps, deps) => Object.assign({}, allDeps, pkg[deps]), {})
    const savedDeps = Object.keys(savedDepsMap)
    const modules = path.join(root, 'node_modules')
    const pkgsInFS = await getPkgsInFS(modules)
    const extraneousPkgs = pkgsInFS.filter((pkgInFS: string) => savedDeps.indexOf(pkgInFS) === -1)
    return extraneousPkgs
  }
  
  const prodDepTypes = ['dependencies', 'optionalDependencies']
  const devOnlyDepTypes = ['devDependencies']
  
  function getSaveTypes (production: boolean) {
    if (production) {
      return prodDepTypes
    }
    return prodDepTypes.concat(devOnlyDepTypes)
  }
  
  async function getPkgsInFS (modules: string): Promise<string[]> {
    const pkgDirs = await getPkgDirs(modules)
    const pkgs: Package[] = await Promise.all(pkgDirs.map(readPkgFromDir))
    return pkgs.map(pkg => pkg.name)
  }
  