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-cli')
14 var EXEC_OPTS = { cwd: pkg }
20 'test-package-with-one-dep': '0.0.0'
24 test('setup', function (t) {
28 path.join(pkg, 'package.json'),
29 JSON.stringify(json, null, 2)
31 mr({ port: common.port }, function (er, s) {
34 '--registry', common.registry,
39 t.ifError(er, 'setup installation ran without issue')
48 test('npm ls --depth=0', function (t) {
52 function (er, c, out) {
53 t.ifError(er, 'npm ls ran without issue')
54 t.equal(c, 0, 'ls ran without raising error code')
57 /test-package-with-one-dep@0\.0\.0/,
58 'output contains test-package-with-one-dep@0.0.0'
62 /test-package@0\.0\.0/,
63 'output not contains test-package@0.0.0'
70 test('npm ls --depth=1', function (t) {
74 function (er, c, out) {
75 t.ifError(er, 'npm ls ran without issue')
76 t.equal(c, 0, 'ls ran without raising error code')
79 /test-package-with-one-dep@0\.0\.0/,
80 'output contains test-package-with-one-dep@0.0.0'
84 /test-package@0\.0\.0/,
85 'output contains test-package@0.0.0'
92 test('npm ls --depth=Infinity', function (t) {
93 // travis has a preconfigured depth=0, in general we can not depend
94 // on the default value in all environments, so explictly set it here
96 ['ls', '--depth=Infinity'],
98 function (er, c, out) {
99 t.ifError(er, 'npm ls ran without issue')
100 t.equal(c, 0, 'ls ran without raising error code')
103 /test-package-with-one-dep@0\.0\.0/,
104 'output contains test-package-with-one-dep@0.0.0'
108 /test-package@0\.0\.0/,
109 'output contains test-package@0.0.0'
116 test('npm ls --depth=0 --json', function (t) {
118 ['ls', '--depth=0', '--json'],
120 function (er, c, out) {
121 t.ifError(er, 'npm ls ran without issue')
122 t.equal(c, 0, 'ls ran without raising error code')
125 /test-package-with-one-dep@0\.0\.0/,
126 'output contains test-package-with-one-dep@0.0.0'
130 /test-package@0\.0\.0/,
131 'output not contains test-package@0.0.0'
138 test('npm ls --depth=Infinity --json', function (t) {
139 // travis has a preconfigured depth=0, in general we can not depend
140 // on the default value in all environments, so explictly set it here
142 ['ls', '--depth=Infinity', '--json'],
144 function (er, c, out) {
145 t.ifError(er, 'npm ls ran without issue')
146 t.equal(c, 0, 'ls ran without raising error code')
149 /test-package-with-one-dep@0\.0\.0/,
150 'output contains test-package-with-one-dep@0.0.0'
154 /test-package@0\.0\.0/,
155 'output contains test-package@0.0.0'
162 test('cleanup', function (t) {
167 function cleanup () {
168 process.chdir(osenv.tmpdir())