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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
var cat = require('graceful-fs').writeFileSync
var resolve = require('path').resolve
var mkdirp = require('mkdirp')
var mr = require('npm-registry-mock')
var rimraf = require('rimraf')
var test = require('tap').test
var tmpdir = require('osenv').tmpdir
var common = require('../common-tap.js')
var pkg = resolve(__dirname, 'ls-l-depth-0')
var dep = resolve(pkg, 'deps', 'glock')
var modules = resolve(pkg, 'node_modules')
var expected =
'\n' +
'│ ' + pkg + '\n' +
'│ \n' +
'└── glock@1.8.7\n' +
' an inexplicably hostile sample package\n' +
' git+https://github.com/npm/glo.ck.git\n' +
' https://glo.ck\n' +
'\n'
var server
var EXEC_OPTS = { cwd: pkg }
var fixture = {
'name': 'glock',
'version': '1.8.7',
'private': true,
'description': 'an inexplicably hostile sample package',
'homepage': 'https://glo.ck',
'repository': 'https://github.com/npm/glo.ck',
'dependencies': {
'underscore': '1.5.1'
}
}
test('setup', function (t) {
setup()
mr({ port: common.port }, function (er, s) {
server = s
t.end()
})
})
test('#6311: npm ll --depth=0 duplicates listing', function (t) {
common.npm(
[
'--loglevel', 'silent',
'--registry', common.registry,
'install', dep
],
EXEC_OPTS,
function (err, code, stdout, stderr) {
t.ifError(err, 'npm install ran without error')
t.notOk(code, 'npm install exited cleanly')
t.notOk(stderr, 'npm install ran silently')
t.equal(
stdout.trim(),
resolve(__dirname, 'ls-l-depth-0') +
'\n└─┬ glock@1.8.7 ' +
'\n └── underscore@1.5.1',
'got expected install output'
)
common.npm(
[
'--loglevel', 'silent',
'ls', '--long',
'--depth', '0'
],
EXEC_OPTS,
function (err, code, stdout, stderr) {
t.ifError(err, 'npm ll ran without error')
t.is(code, 1, 'npm ll complained about there being no package.json')
t.notOk(stderr, 'npm ll ran silently')
t.equal(
stdout,
expected,
'got expected package name'
)
t.end()
}
)
}
)
})
test('cleanup', function (t) {
cleanup()
server.close()
t.end()
})
function cleanup () {
process.chdir(tmpdir())
rimraf.sync(pkg)
}
function setup () {
cleanup()
mkdirp.sync(modules)
mkdirp.sync(dep)
cat(resolve(dep, 'package.json'), JSON.stringify(fixture))
}
|