]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/false-name.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / false-name.js
1 // this is a test for fix #2538
2
3 // the false_name-test-package has the name property 'test-package' set
4 // in the package.json and a dependency named 'test-package' is also a
5 // defined dependency of 'test-package-with-one-dep'.
6 //
7 // this leads to a conflict during installation and the fix is covered
8 // by this test
9
10 var fs = require('graceful-fs')
11 var path = require('path')
12 var existsSync = fs.existsSync || path.existsSync
13
14 var mkdirp = require('mkdirp')
15 var mr = require('npm-registry-mock')
16 var rimraf = require('rimraf')
17 var test = require('tap').test
18
19 var common = require('../common-tap.js')
20
21 var pkg = path.join(__dirname, 'false-name')
22 var cache = path.join(pkg, 'cache')
23 var server
24
25 var EXEC_OPTS = { cwd: pkg }
26
27 var indexContent = 'module.exports = true\n'
28 var json = {
29   name: 'test-package',
30   version: '0.0.0',
31   main: 'index.js',
32   dependencies: {
33     'test-package-with-one-dep': '0.0.0'
34   }
35 }
36
37 test('setup', function (t) {
38   t.comment('test for https://github.com/npm/npm/issues/2538')
39   setup()
40   mr({ port: common.port }, function (er, s) {
41     server = s
42     t.end()
43   })
44 })
45
46 test('not every pkg.name can be required', function (t) {
47   common.npm(
48     [
49       'install', '.',
50       '--cache', cache,
51       '--registry', common.registry
52     ],
53     EXEC_OPTS,
54     function (err, code) {
55       t.ifErr(err, 'install finished without error')
56       t.equal(code, 0, 'install exited ok')
57       t.ok(existsSync(path.join(
58         pkg,
59         'node_modules/test-package-with-one-dep',
60         'node_modules/test-package'
61       )), 'package installed OK')
62       t.end()
63     }
64   )
65 })
66
67 test('cleanup', function (t) {
68   server.close()
69   cleanup()
70   t.end()
71 })
72
73 function cleanup () {
74   rimraf.sync(pkg)
75 }
76
77 function setup () {
78   cleanup()
79   mkdirp.sync(cache)
80   fs.writeFileSync(
81     path.join(pkg, 'package.json'),
82     JSON.stringify(json, null, 2)
83   )
84   fs.writeFileSync(path.join(pkg, 'index.js'), indexContent)
85 }