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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
var fs = require('graceful-fs')
var path = require('path')
var mr = require('npm-registry-mock')
var test = require('tap').test
var common = require('../common-tap.js')
var npm = require('../../')
var pkg = common.pkg
var json = {
author: 'Anders Janmyr',
name: 'dev-dep-duplicate',
version: '0.0.0',
dependencies: {
underscore: '1.5.1'
},
devDependencies: {
underscore: '1.3.1'
}
}
var expected = {
name: 'dev-dep-duplicate',
version: '0.0.0',
dependencies: {
underscore: {
version: '1.5.1',
from: 'underscore@1.5.1',
resolved: common.registry + '/underscore/-/underscore-1.5.1.tgz',
invalid: true
}
}
}
test('prefers version from dependencies over devDependencies', function (t) {
t.plan(1)
mr({ port: common.port }, function (er, s) {
setup(function (err) {
if (err) {
throw err
}
npm.install('.', function (err) {
if (err) {
throw err
}
npm.commands.ls([], true, function (err, _, results) {
if (err) {
throw err
}
// these contain full paths so we can't do an exact match
// with them
delete results.problems
delete results.dependencies.underscore.problems
t.deepEqual(results, expected)
s.close()
t.end()
})
})
})
})
})
function setup (cb) {
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
process.chdir(pkg)
var opts = {
cache: common.cache,
registry: common.registry
}
npm.load(opts, cb)
}
|