1 var fs = require('graceful-fs')
2 var path = require('path')
3 var existsSync = fs.existsSync || path.existsSync
5 var mkdirp = require('mkdirp')
6 var mr = require('npm-registry-mock')
7 var rimraf = require('rimraf')
8 var test = require('tap').test
10 var common = require('../common-tap.js')
13 var pkg = path.join(__dirname, 'dedupe')
15 var EXEC_OPTS = { cwd: pkg }
18 author: 'Dedupe tester',
27 test('setup', function (t) {
28 t.comment('test for https://github.com/npm/npm/issues/4675')
34 test('dedupe finds the common module and moves it up one level', function (t) {
37 '--registry', common.registry,
41 function (err, code) {
42 t.ifError(err, 'successfully installed directory')
43 t.equal(code, 0, 'npm install exited with code')
49 function (err, code) {
50 t.ifError(err, 'successfully deduped against previous install')
51 t.notOk(code, 'npm dedupe exited with code')
53 t.ok(existsSync(path.join(pkg, 'node_modules', 'minimist')))
54 t.notOk(existsSync(path.join(pkg, 'node_modules', 'checker')))
62 test('cleanup', function (t) {
75 mkdirp.sync(path.join(pkg, 'node_modules'))
77 path.join(pkg, 'package.json'),
78 JSON.stringify(json, null, 2)
82 mr({ port: common.port }, function (er, s) {