Welcome to mirror list, hosted at ThFree Co, Russian Federation.

install-lifecycle.js « tap « test « npm « deps - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c5b0fd35a020e5d1fb90bcbf45eb566aab4f3e10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var fs = require('graceful-fs')
var path = require('path')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = common.pkg

test('npm install execution order', function (t) {
  const packageJson = {
    name: 'life-test',
    version: '0.0.1',
    description: 'Test for npm install execution order',
    scripts: {
      install: 'true',
      preinstall: 'true',
      preshrinkwrap: 'true',
      postinstall: 'true',
      postshrinkwrap: 'true',
      shrinkwrap: 'true'
    }
  }
  fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify(packageJson), 'utf8')
  common.npm(['install', '--loglevel=error'], { cwd: pkg }, function (err, code, stdout, stderr) {
    if (err) throw err

    t.comment(stdout)
    t.comment(stderr)

    const steps = ['preinstall', 'install', 'postinstall', 'preshrinkwrap', 'shrinkwrap', 'postshrinkwrap']
    const expectedLines = steps.map(function (step) {
      return '> ' + packageJson.name + '@' + packageJson.version + ' ' + step
    })
    t.match(stdout, new RegExp(expectedLines.map(common.escapeForRe).join('(.|\n)*')))
    t.end()
  })
})