hunk.code_window:     }
       const newShr = await pruneShrinkwrap(ctx.shrinkwrap, pkg)
       const removedPkgIds = await removeOrphanPkgs(ctx.privateShrinkwrap, newShr, ctx.root, ctx.storePath)
       await saveShrinkwrap(ctx.root, newShr)
       await saveModules(path.join(ctx.root, 'node_modules'), {
         packageManager: `${pnpmPkgJson.name}@${pnpmPkgJson.version}`,
         storePath: ctx.storePath,
         skipped: Array.from(ctx.skipped).filter(pkgId => removedPkgIds.indexOf(pkgId) === -1),
       })
       await removeOuterLinks(pkgsToUninstall, path.join(ctx.root, 'node_modules'), {storePath: ctx.storePath})
     }
  
hunk.labels: keep replace replace replace replace replace replace replace replace replace keep
hunk.file_path: src/api/uninstall.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 'pnpm-lockfile'
  
  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 = !opts.production ? ctx.pkg : {
        dependencies: ctx.pkg.dependencies,
        optionalDependencies: ctx.pkg.optionalDependencies,
      } as Package
  
      const prunedShr = pruneShrinkwrap(ctx.shrinkwrap, pkg)
  
      await removeOrphanPkgs(ctx.privateShrinkwrap, prunedShr, ctx.root, ctx.storePath)
    }
  }
  