]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/ls-depth-cli.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / ls-depth-cli.js
1 var fs = require('graceful-fs')
2 var path = require('path')
3
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
9
10 var common = require('../common-tap')
11
12 var pkg = path.resolve(__dirname, 'ls-depth-cli')
13
14 var EXEC_OPTS = { cwd: pkg }
15
16 var json = {
17   name: 'ls-depth-cli',
18   version: '0.0.0',
19   dependencies: {
20     'test-package-with-one-dep': '0.0.0'
21   }
22 }
23
24 test('setup', function (t) {
25   cleanup()
26   mkdirp.sync(pkg)
27   fs.writeFileSync(
28     path.join(pkg, 'package.json'),
29     JSON.stringify(json, null, 2)
30   )
31   mr({ port: common.port }, function (er, s) {
32     common.npm(
33       [
34         '--registry', common.registry,
35         'install'
36       ],
37       EXEC_OPTS,
38       function (er, c) {
39         t.ifError(er, 'setup installation ran without issue')
40         t.equal(c, 0)
41         s.close()
42         t.end()
43       }
44     )
45   })
46 })
47
48 test('npm ls --depth=0', function (t) {
49   common.npm(
50     ['ls', '--depth=0'],
51     EXEC_OPTS,
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')
55       t.has(
56         out,
57         /test-package-with-one-dep@0\.0\.0/,
58         'output contains test-package-with-one-dep@0.0.0'
59       )
60       t.doesNotHave(
61         out,
62         /test-package@0\.0\.0/,
63         'output not contains test-package@0.0.0'
64       )
65       t.end()
66     }
67   )
68 })
69
70 test('npm ls --depth=1', function (t) {
71   common.npm(
72     ['ls', '--depth=1'],
73     EXEC_OPTS,
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')
77       t.has(
78         out,
79         /test-package-with-one-dep@0\.0\.0/,
80         'output contains test-package-with-one-dep@0.0.0'
81       )
82       t.has(
83         out,
84         /test-package@0\.0\.0/,
85         'output contains test-package@0.0.0'
86       )
87       t.end()
88     }
89   )
90 })
91
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
95   common.npm(
96     ['ls', '--depth=Infinity'],
97     EXEC_OPTS,
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')
101       t.has(
102         out,
103         /test-package-with-one-dep@0\.0\.0/,
104         'output contains test-package-with-one-dep@0.0.0'
105       )
106       t.has(
107         out,
108         /test-package@0\.0\.0/,
109         'output contains test-package@0.0.0'
110       )
111       t.end()
112     }
113   )
114 })
115
116 test('npm ls --depth=0 --json', function (t) {
117   common.npm(
118     ['ls', '--depth=0', '--json'],
119     EXEC_OPTS,
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')
123       t.has(
124         out,
125         /test-package-with-one-dep@0\.0\.0/,
126         'output contains test-package-with-one-dep@0.0.0'
127       )
128       t.doesNotHave(
129         out,
130         /test-package@0\.0\.0/,
131         'output not contains test-package@0.0.0'
132       )
133       t.end()
134     }
135   )
136 })
137
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
141   common.npm(
142     ['ls', '--depth=Infinity', '--json'],
143     EXEC_OPTS,
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')
147       t.has(
148         out,
149         /test-package-with-one-dep@0\.0\.0/,
150         'output contains test-package-with-one-dep@0.0.0'
151       )
152       t.has(
153         out,
154         /test-package@0\.0\.0/,
155         'output contains test-package@0.0.0'
156       )
157       t.end()
158     }
159   )
160 })
161
162 test('cleanup', function (t) {
163   cleanup()
164   t.end()
165 })
166
167 function cleanup () {
168   process.chdir(osenv.tmpdir())
169   rimraf.sync(pkg)
170 }