hunk.code_window:   PackageSpec,
     PackageMeta,
   } from '../resolve'
   import mkdirp = require('mkdirp-promise')
   import pkgIdToFilename from '../fs/pkgIdToFilename'
   import {fromDir as readPkgFromDir} from '../fs/readPkg'
   import exists = require('path-exists')
   import memoize, {MemoizedFunc} from '../memoize'
   import {Package} from '../types'
  
hunk.labels: keep keep keep add keep keep keep keep keep
hunk.after_edit: import thenify = require('thenify')
   import writeFileAtomicCB = require('write-file-atomic')
  
hunk.file_path: src/install/fetch.ts
hunk.type: add
file: import rimraf = require('rimraf-then')
  import path = require('path')
  import binify from './binify'
  import {fromDir as safeReadPkgFromDir} from './fs/safeReadPkg'
  
  export default async function removeTopDependency (dependencyName: string, modules: string) {
    return Promise.all([
      removeBins(dependencyName, modules),
      rimraf(path.join(modules, dependencyName)),
    ])
  }
  
  async function removeBins (uninstalledPkg: string, modules: string) {
    const uninstalledPkgPath = path.join(modules, uninstalledPkg)
    const uninstalledPkgJson = await safeReadPkgFromDir(uninstalledPkgPath)
    if (!uninstalledPkgJson) return
    const cmds = await binify(uninstalledPkgJson, uninstalledPkgPath)
    return Promise.all(
      cmds.map(cmd => path.join(modules, '.bin', cmd.name)).map(rimraf)
    )
  }
  