hunk.code_window: import { REGISTRY_MOCK_PORT } from '@pnpm/registry-mock'
   import loadJsonFile = require('load-json-file')
   import path = require('path')
   import test = require('tape')
   const REGISTRY_URL = `http://localhost:${REGISTRY_MOCK_PORT}`
   const DEFAULT_OPTIONS = {
  
hunk.labels: keep keep keep add keep keep keep keep
hunk.after_edit: import tempy = require('tempy')
  
hunk.file_path: packages/plugin-commands-installation/test/add.ts
hunk.type: add
file: import { WANTED_LOCKFILE } from '@pnpm/constants'
  import { readProjects } from '@pnpm/filter-workspace-packages'
  import { install, link, unlink } from '@pnpm/plugin-commands-installation'
  import { preparePackages } from '@pnpm/prepare'
  import path = require('path')
  import exists = require('path-exists')
  import test = require('tape')
  import { DEFAULT_OPTS } from './utils'
  
  test('recursive linking/unlinking', async (t) => {
    const projects = preparePackages(t, [
      {
        name: 'project-1',
        version: '1.0.0',
  
        devDependencies: {
          'is-positive': '1.0.0',
        },
      },
      {
        name: 'is-positive',
        version: '1.0.0',
  
        dependencies: {
          'is-negative': '1.0.0',
        },
      },
    ])
  
    const { allProjects, selectedProjectsGraph } = await readProjects(process.cwd(), [])
    await install.handler({
      ...DEFAULT_OPTS,
      allProjects,
      dir: process.cwd(),
      recursive: true,
      selectedProjectsGraph,
      workspaceDir: process.cwd(),
    })
  
    t.ok(projects['is-positive'].requireModule('is-negative'))
    t.notOk(projects['project-1'].requireModule('is-positive/package.json').author, 'local package is linked')
  
    {
      const project1Lockfile = await projects['project-1'].readLockfile()
      t.equal(project1Lockfile.devDependencies['is-positive'], 'link:../is-positive')
    }
  
    await unlink.handler({
      ...DEFAULT_OPTS,
      allProjects,
      dir: process.cwd(),
      recursive: true,
      selectedProjectsGraph,
      workspaceDir: process.cwd(),
    }, [])
  
    process.chdir('project-1')
    t.ok(await exists(path.resolve('node_modules', 'is-positive', 'index.js')), 'local package is unlinked')
  
    {
      const project1Lockfile = await projects['project-1'].readLockfile()
      t.equal(project1Lockfile.lockfileVersion, 5.1, `project-1 has correct lockfileVersion specified in ${WANTED_LOCKFILE}`)
      t.equal(project1Lockfile.devDependencies['is-positive'], '1.0.0')
      t.ok(project1Lockfile.packages['/is-positive/1.0.0'])
    }
  
    const isPositiveLockfile = await projects['is-positive'].readLockfile()
    t.equal(isPositiveLockfile.lockfileVersion, 5.1, `is-positive has correct lockfileVersion specified in ${WANTED_LOCKFILE}`)
  
    t.end()
  })
  
  test('recursive unlink specific package', async (t) => {
    const projects = preparePackages(t, [
      {
        name: 'project-1',
        version: '1.0.0',
  
        devDependencies: {
          'is-positive': '1.0.0',
        },
      },
      {
        name: 'is-positive',
        version: '1.0.0',
  
        dependencies: {
          'is-negative': '1.0.0',
        },
      },
    ])
  
    const { allProjects, selectedProjectsGraph } = await readProjects(process.cwd(), [])
    await install.handler({
      ...DEFAULT_OPTS,
      allProjects,
      dir: process.cwd(),
      recursive: true,
      selectedProjectsGraph,
      workspaceDir: process.cwd(),
    })
  
    t.ok(projects['is-positive'].requireModule('is-negative'))
    t.notOk(projects['project-1'].requireModule('is-positive/package.json').author, 'local package is linked')
  
    {
      const project1Lockfile = await projects['project-1'].readLockfile()
      t.equal(project1Lockfile.devDependencies['is-positive'], 'link:../is-positive')
    }
  
    await unlink.handler({
      ...DEFAULT_OPTS,
      allProjects,
      dir: process.cwd(),
      recursive: true,
      selectedProjectsGraph,
      workspaceDir: process.cwd(),
    }, ['is-positive'])
  
    process.chdir('project-1')
    t.ok(await exists(path.resolve('node_modules', 'is-positive', 'index.js')), 'local package is unlinked')
  
    {
      const project1Lockfile = await projects['project-1'].readLockfile()
      t.equal(project1Lockfile.lockfileVersion, 5.1, `project-1 has correct lockfileVersion specified in ${WANTED_LOCKFILE}`)
      t.equal(project1Lockfile.devDependencies['is-positive'], '1.0.0')
      t.ok(project1Lockfile.packages['/is-positive/1.0.0'])
    }
  
    const isPositiveLockfile = await projects['is-positive'].readLockfile()
    t.equal(isPositiveLockfile.lockfileVersion, 5.1, `is-positive has correct lockfileVersion specified in ${WANTED_LOCKFILE}`)
  
    t.end()
  })
  