]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/dedupe.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / dedupe.js
1 var fs = require('graceful-fs')
2 var path = require('path')
3 var existsSync = fs.existsSync || path.existsSync
4
5 var mkdirp = require('mkdirp')
6 var mr = require('npm-registry-mock')
7 var rimraf = require('rimraf')
8 var test = require('tap').test
9
10 var common = require('../common-tap.js')
11 var server
12
13 var pkg = path.join(__dirname, 'dedupe')
14
15 var EXEC_OPTS = { cwd: pkg }
16
17 var json = {
18   author: 'Dedupe tester',
19   name: 'dedupe',
20   version: '0.0.0',
21   dependencies: {
22     optimist: '0.6.0',
23     clean: '2.1.6'
24   }
25 }
26
27 test('setup', function (t) {
28   t.comment('test for https://github.com/npm/npm/issues/4675')
29   setup(function () {
30     t.end()
31   })
32 })
33
34 test('dedupe finds the common module and moves it up one level', function (t) {
35   common.npm(
36   [
37     '--registry', common.registry,
38     'install', '.'
39   ],
40   EXEC_OPTS,
41   function (err, code) {
42     t.ifError(err, 'successfully installed directory')
43     t.equal(code, 0, 'npm install exited with code')
44     common.npm(
45       [
46         'dedupe'
47       ],
48       EXEC_OPTS,
49       function (err, code) {
50         t.ifError(err, 'successfully deduped against previous install')
51         t.notOk(code, 'npm dedupe exited with code')
52
53         t.ok(existsSync(path.join(pkg, 'node_modules', 'minimist')))
54         t.notOk(existsSync(path.join(pkg, 'node_modules', 'checker')))
55
56         t.end()
57       }
58     )
59   })
60 })
61
62 test('cleanup', function (t) {
63   server.close()
64   cleanup()
65
66   t.end()
67 })
68
69 function cleanup () {
70   rimraf.sync(pkg)
71 }
72
73 function setup (cb) {
74   cleanup()
75   mkdirp.sync(path.join(pkg, 'node_modules'))
76   fs.writeFileSync(
77     path.join(pkg, 'package.json'),
78     JSON.stringify(json, null, 2)
79   )
80   process.chdir(pkg)
81
82   mr({ port: common.port }, function (er, s) {
83     server = s
84     cb()
85   })
86 }