1 // this is a test for fix #2538
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'.
7 // this leads to a conflict during installation and the fix is covered
10 var fs = require('graceful-fs')
11 var path = require('path')
12 var existsSync = fs.existsSync || path.existsSync
14 var mkdirp = require('mkdirp')
15 var mr = require('npm-registry-mock')
16 var rimraf = require('rimraf')
17 var test = require('tap').test
19 var common = require('../common-tap.js')
21 var pkg = path.join(__dirname, 'false-name')
22 var cache = path.join(pkg, 'cache')
25 var EXEC_OPTS = { cwd: pkg }
27 var indexContent = 'module.exports = true\n'
33 'test-package-with-one-dep': '0.0.0'
37 test('setup', function (t) {
38 t.comment('test for https://github.com/npm/npm/issues/2538')
40 mr({ port: common.port }, function (er, s) {
46 test('not every pkg.name can be required', function (t) {
51 '--registry', common.registry
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(
59 'node_modules/test-package-with-one-dep',
60 'node_modules/test-package'
61 )), 'package installed OK')
67 test('cleanup', function (t) {
81 path.join(pkg, 'package.json'),
82 JSON.stringify(json, null, 2)
84 fs.writeFileSync(path.join(pkg, 'index.js'), indexContent)