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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
var fs = require('fs')
var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = common.pkg
var local = path.join(pkg, 'package')
var EXEC_OPTS = { }
var json = {
name: '@scope/package',
version: '0.0.0',
peerDependencies: {
underscore: '*'
}
}
test('setup', function (t) {
setup()
t.end()
})
test('it should install peerDependencies in same tree level as the parent package', function (t) {
common.npm(['install', '--loglevel=warn', './package'], EXEC_OPTS, function (err, code, stdout, stderr) {
t.ifError(err, 'install local package successful')
t.equal(code, 0, 'npm install exited with code')
t.match(stderr, /npm WARN @scope[/]package@0[.]0[.]0 requires a peer of underscore@[*] but none is installed[.] You must install peer dependencies yourself[.]\n/,
'npm install warned about unresolved peer dep')
t.end()
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup () {
cleanup()
mkdirp.sync(local)
mkdirp.sync(path.resolve(pkg, 'node_modules'))
fs.writeFileSync(
path.join(local, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}
|