• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1var fs = require('graceful-fs')
2var path = require('path')
3
4var mr = require('npm-registry-mock')
5var test = require('tap').test
6
7var common = require('../common-tap.js')
8var npm = require('../../')
9
10var pkg = common.pkg
11
12var expected = [ 'peer dep missing: request@0.9.x, required by npm-test-peer-deps@0.0.0' ]
13
14var json = {
15  author: 'Domenic Denicola',
16  name: 'npm-test-peer-deps-installer',
17  version: '0.0.0',
18  dependencies: {
19    'npm-test-peer-deps': '*'
20  }
21}
22
23function setup (cb) {
24  fs.writeFileSync(
25    path.join(pkg, 'package.json'),
26    JSON.stringify(json, null, 2)
27  )
28  process.chdir(pkg)
29
30  var opts = { cache: common.cache, registry: common.registry }
31  npm.load(opts, cb)
32}
33
34test('installs the peer dependency directory structure', function (t) {
35  mr({ port: common.port }, function (er, s) {
36    setup(function (err) {
37      if (err) return t.fail(err)
38
39      npm.install('.', function (err) {
40        if (err) return t.fail(err)
41
42        npm.commands.ls([], true, function (err, _, results) {
43          if (err) return t.fail(err)
44
45          t.deepEqual(results.problems, expected)
46          s.close()
47          t.end()
48        })
49      })
50    })
51  })
52})
53