1 var fs = require('graceful-fs')
2 var path = require('path')
4 var mkdirp = require('mkdirp')
5 var mr = require('npm-registry-mock')
6 var osenv = require('osenv')
7 var rimraf = require('rimraf')
8 var test = require('tap').test
10 var common = require('../common-tap')
12 var pkg = path.resolve(__dirname, 'ls-depth-unmet')
14 var EXEC_OPTS = { cwd: pkg }
17 name: 'ls-depth-umnet',
21 'test-package-with-one-dep': '0.0.0',
27 test('setup', function (t) {
31 path.join(pkg, 'package.json'),
32 JSON.stringify(json, null, 2)
34 mr({ port: common.port }, function (er, s) {
37 '--registry', common.registry,
38 'install', 'underscore@1.3.1', 'mkdirp', 'test-package-with-one-dep'
42 t.ifError(er, 'setup installation ran without issue')
51 test('npm ls --depth=0', function (t) {
55 function (er, c, out) {
56 t.ifError(er, 'setup installation ran without issue')
57 t.equal(c, 1, 'ls barfed')
60 /UNMET DEPENDENCY optimist@0\.6\.0/,
61 'output contains optimist@0.6.0 and labeled as unmet dependency'
65 /mkdirp@0\.3\.5 extraneous/,
66 'output contains mkdirp@0.3.5 and labeled as extraneous'
70 /underscore@1\.3\.1 invalid/,
71 'output contains underscore@1.3.1 and labeled as invalid'
75 /test-package-with-one-dep@0\.0\.0\n/,
76 'output contains test-package-with-one-dep@0.0.0 and has no labels'
80 /test-package@0\.0\.0/,
81 'output does not contain test-package@0.0.0 which is at depth=1'
88 test('npm ls --depth=1', function (t) {
92 function (er, c, out) {
93 t.ifError(er, 'setup installation ran without issue')
94 t.equal(c, 1, 'ls barfed')
97 /UNMET DEPENDENCY optimist@0\.6\.0/,
98 'output contains optimist@0.6.0 and labeled as unmet dependency'
102 /mkdirp@0\.3\.5 extraneous/,
103 'output contains mkdirp@0.3.5 and labeled as extraneous'
107 /underscore@1\.3\.1 invalid/,
108 'output contains underscore@1.3.1 and labeled as invalid'
112 /test-package-with-one-dep@0\.0\.0\n/,
113 'output contains test-package-with-one-dep@0.0.0 and has no labels'
117 /test-package@0\.0\.0/,
118 'output contains test-package@0.0.0 which is at depth=1'
125 test('npm ls --depth=Infinity', function (t) {
126 // travis has a preconfigured depth=0, in general we can not depend
127 // on the default value in all environments, so explictly set it here
129 ['ls', '--depth=Infinity'],
131 function (er, c, out) {
132 t.ifError(er, 'setup installation ran without issue')
133 t.equal(c, 1, 'ls barfed')
136 /UNMET DEPENDENCY optimist@0\.6\.0/,
137 'output contains optimist@0.6.0 and labeled as unmet dependency'
141 /mkdirp@0\.3\.5 extraneous/,
142 'output contains mkdirp@0.3.5 and labeled as extraneous'
146 /underscore@1\.3\.1 invalid/,
147 'output contains underscore@1.3.1 and labeled as invalid'
151 /test-package-with-one-dep@0\.0\.0\n/,
152 'output contains test-package-with-one-dep@0.0.0 and has no labels'
156 /test-package@0\.0\.0/,
157 'output contains test-package@0.0.0 which is at depth=1'
164 test('cleanup', function (t) {
169 function cleanup () {
170 process.chdir(osenv.tmpdir())