hunk.code_window: async function createShasum(dirPath: string) {
     try {
       const shasum = await dirsum(dirPath)
       await fs.writeFile(`${dirPath}_shasum`, shasum, 'utf8')
     } catch (err) {
       logger.error({
         message: `Failed to calculate shasum for ${dirPath}`,
         err,
       })
  
hunk.labels: keep keep keep keep replace keep keep keep keep keep
hunk.after_edit:     await writeFileAtomic(`${dirPath}_shasum`, shasum, 'utf8')
  
hunk.file_path: src/install/fetch.ts
hunk.type: replace
file: import path = require('path')
  import normalizePath = require('normalize-path')
  import fs = require('mz/fs')
  import mkdirp = require('mkdirp-promise')
  import {fromDir as safeReadPkgFromDir} from '../fs/safeReadPkg'
  import getPkgDirs from '../fs/getPkgDirs'
  import binify from '../binify'
  import isWindows = require('is-windows')
  import cmdShim = require('@zkochan/cmd-shim')
  import logger from 'pnpm-logger'
  import Module = require('module')
  import R = require('ramda')
  
  const IS_WINDOWS = isWindows()
  
  export default async function linkAllBins (modules: string, binPath: string, exceptPkgName?: string) {
    const pkgDirs = await getPkgDirs(modules)
    return Promise.all(
      pkgDirs
        .map(pkgDir => normalizePath(pkgDir))
        .filter(pkgDir => !exceptPkgName || !pkgDir.endsWith(`/${exceptPkgName}`))
        .map((pkgDir: string) => linkPkgBins(pkgDir, binPath))
    )
  }
  
  /**
   * Links executable into `node_modules/.bin`.
   */
  export async function linkPkgBins (target: string, binPath: string) {
    const pkg = await safeReadPkgFromDir(target)
  
    if (!pkg) {
      logger.warn(`There's a directory in node_modules without package.json: ${target}`)
      return
    }
  
    const cmds = await binify(pkg, target)
  
    await mkdirp(binPath)
    await Promise.all(cmds.map(async cmd => {
      const externalBinPath = path.join(binPath, cmd.name)
  
      const nodePath = (await getBinNodePaths(target)).join(path.delimiter)
      return cmdShim(cmd.path, externalBinPath, {nodePath})
    }))
  }
  
  async function getBinNodePaths (target: string) {
    const targetRealPath = await fs.realpath(target)
  
    return R.union(
      Module._nodeModulePaths(targetRealPath),
      Module._nodeModulePaths(target)
    )
  }
  