hunk.code_window:   exists-link: 2.0.0
     is-ci: 1.0.10
     isexe: 2.0.0
     mkdirp: 0.5.1
     npm-run-all: 4.1.1
     pnpm-registry-mock: 1.7.0
     read-pkg: 2.0.0
     rimraf: 2.6.2
     sepia: 2.0.2
     sinon: 2.4.1
     tape: 4.8.0
  
hunk.labels: keep keep keep keep keep replace keep keep keep keep keep
hunk.after_edit:   pnpm-registry-mock: 1.8.0
  
hunk.file_path: test/shrinkwrap.yaml
hunk.type: replace
file: import logger from 'pnpm-logger'
  import path = require('path')
  import isInnerLink = require('is-inner-link')
  import fs = require('mz/fs')
  import mkdirp = require('mkdirp-promise')
  import isSubdir = require('is-subdir')
  
  export default async function safeIsInnerLink (
    modules: string,
    depName: string,
    opts: {
      storePath: string,
    }
  ) {
    try {
      const link = await isInnerLink(modules, depName)
  
      if (link.isInner) return true
  
      if (isSubdir(opts.storePath, link.target)) return true
  
      logger.info(`${depName} is linked to ${modules} from ${link.target}`)
      return false
    } catch (err) {
      if (err.code === 'ENOENT') return true
  
      logger.warn(`Moving ${depName} that was installed by a different package manager to "node_modules/.ignored`)
      const ignoredDir = path.join(modules, '.ignored', depName)
      await mkdirp(path.dirname(ignoredDir))
      await fs.rename(
        path.join(modules, depName),
        ignoredDir)
      return true
    }
  }
  