• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1var fs = require('graceful-fs')
2var path = require('path')
3var test = require('tap').test
4var common = require('../common-tap.js')
5var pkg = common.pkg
6
7test('npm shrinkwrap execution order', function (t) {
8  fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify({
9    author: 'Simen Bekkhus',
10    name: 'shrinkwrap-lifecycle',
11    shrinkwrap: '0.0.0',
12    description: 'Test for npm shrinkwrap execution order',
13    scripts: {
14      preshrinkwrap: 'echo this happens first',
15      shrinkwrap: 'echo this happens second',
16      postshrinkwrap: 'echo this happens third'
17    }
18  }), 'utf8')
19  common.npm(['shrinkwrap', '--loglevel=error'], { cwd: pkg }, function (err, code, stdout, stderr) {
20    if (err) throw err
21
22    t.comment(stdout)
23    t.comment(stderr)
24    var indexOfFirst = stdout.indexOf('echo this happens first')
25    var indexOfSecond = stdout.indexOf('echo this happens second')
26    var indexOfThird = stdout.indexOf('echo this happens third')
27
28    t.ok(indexOfFirst >= 0)
29    t.ok(indexOfSecond >= 0)
30    t.ok(indexOfThird >= 0)
31
32    t.ok(indexOfFirst < indexOfSecond)
33    t.ok(indexOfSecond < indexOfThird)
34
35    t.end()
36  })
37})
38