hunk.code_window:       node: '>=4'
       resolution:
         integrity: sha512-rKzsDOico9EZPMt6xq/5ulebekkmAhSeivDz+tPArfuGrp3UKg8pJgvPLL/t33YT222Qo4tMSq7kxKX34P4D/w==
     /pnpm-default-reporter/0.14.1:
       dependencies:
         '@types/common-tags': 1.4.0
         '@types/node': 9.4.4
         '@types/ramda': 0.25.17
         '@types/semver': 5.5.0
  
hunk.labels: keep keep keep replace keep keep keep keep keep
hunk.after_edit:   /pnpm-default-reporter/0.14.2:
  
hunk.file_path: shrinkwrap.yaml
hunk.type: replace
file: import tape = require('tape')
  import promisifyTape from 'tape-promise'
  import {install} from 'supi'
  import {
    prepare,
    testDefaults,
    execPnpmSync,
  } from '../utils'
  import path = require('path')
  import loadJsonFile = require('load-json-file')
  import rimraf = require('rimraf-then')
  
  const pkgRoot = path.join(__dirname, '..', '..')
  const pnpmPkg = loadJsonFile.sync(path.join(pkgRoot, 'package.json'))
  
  const test = promisifyTape(tape)
  
  test('installation fails if lifecycle script fails', t => {
    const project = prepare(t, {
      scripts: {
        preinstall: 'exit 1'
      },
    })
  
    const result = execPnpmSync('install')
  
    t.equal(result.status, 1, 'installation failed')
  
    t.end()
  })
  
  test('lifecycle script runs with the correct user agent', t => {
    const project = prepare(t, {
      scripts: {
        preinstall: 'node --eval "console.log(process.env.npm_config_user_agent)"'
      },
    })
  
    const result = execPnpmSync('install')
  
    t.equal(result.status, 0, 'installation was successfull')
    const expectedUserAgentPrefix = `${pnpmPkg.name}/${pnpmPkg.version} `
    t.ok(result.stdout.toString().indexOf(expectedUserAgentPrefix) !== -1, 'correct npm_config_user_agent value')
  
    t.end()
  })
  
  test('preinstall is executed before general installation', t => {
    const project = prepare(t, {
      scripts: {
        preinstall: 'echo "Hello world!"'
      }
    })
  
    const result = execPnpmSync('install')
  
    t.equal(result.status, 0, 'installation was successfull')
    t.ok(result.stdout.toString().indexOf('Hello world!') !== -1, 'preinstall script was executed')
  
    t.end()
  })
  
  test('postinstall is executed after general installation', t => {
    const project = prepare(t, {
      scripts: {
        postinstall: 'echo "Hello world!"'
      }
    })
  
    const result = execPnpmSync('install')
  
    t.equal(result.status, 0, 'installation was successfull')
    t.ok(result.stdout.toString().indexOf('Hello world!') !== -1, 'postinstall script was executed')
  
    t.end()
  })
  
  test('postinstall is not executed after named installation', t => {
    const project = prepare(t, {
      scripts: {
        postinstall: 'echo "Hello world!"'
      }
    })
  
    const result = execPnpmSync('install', 'is-negative')
  
    t.equal(result.status, 0, 'installation was successfull')
    t.ok(result.stdout.toString().indexOf('Hello world!') === -1, 'postinstall script was not executed')
  
    t.end()
  })
  
  test('prepare is not executed after installation with arguments', t => {
    const project = prepare(t, {
      scripts: {
        prepare: 'echo "Hello world!"'
      }
    })
  
    const result = execPnpmSync('install', 'is-negative')
  
    t.equal(result.status, 0, 'installation was successfull')
    t.ok(result.stdout.toString().indexOf('Hello world!') === -1, 'prepare script was not executed')
  
    t.end()
  })
  
  test('prepare is executed after argumentless installation', t => {
    const project = prepare(t, {
      scripts: {
        prepare: 'echo "Hello world!"'
      }
    })
  
    const result = execPnpmSync('install')
  
    t.equal(result.status, 0, 'installation was successfull')
    t.ok(result.stdout.toString().indexOf('Hello world!') !== -1, 'prepare script was executed')
  
    t.end()
  })
  
  test('lifecycle events have proper npm_config_argv', async (t: tape.Test) => {
    const project = prepare(t, {
      scripts: {
        postinstall: 'write-lifecycle-env',
      },
      dependencies: {
        'write-lifecycle-env': '^1.0.0',
      },
    })
  
    execPnpmSync('install')
  
    const lifecycleEnv = await loadJsonFile('env.json')
  
    t.deepEqual(JSON.parse(lifecycleEnv['npm_config_argv']), {
      remain: ['install'],
      cooked: ['install'],
      original: ['install'],
    })
  })
  