1var fs = require('graceful-fs') 2var path = require('path') 3 4var mr = require('npm-registry-mock') 5var test = require('tap').test 6 7var common = require('../common-tap.js') 8var npm = require('../../') 9 10var pkg = common.pkg 11 12var json = { 13 dependencies: { 14 underscore: '1.5.1' 15 }, 16 devDependencies: { 17 underscore: '1.3.1' 18 } 19} 20 21test('npm install with duplicate dependencies, different versions', function (t) { 22 t.plan(1) 23 t.comment('test for https://github.com/npm/npm/issues/6725') 24 25 fs.writeFileSync( 26 path.join(pkg, 'package.json'), 27 JSON.stringify(json, null, 2) 28 ) 29 process.chdir(pkg) 30 31 mr({ port: common.port }, function (er, s) { 32 var opts = { 33 cache: common.cache, 34 registry: common.registry 35 } 36 37 npm.load(opts, function (err) { 38 if (err) return t.fail(err) 39 40 npm.install('.', function (err, additions, result) { 41 if (err) return t.fail(err) 42 43 var invalid = result.warnings.filter(function (warning) { return warning.code === 'EDUPLICATEDEP' }) 44 t.is(invalid.length, 1, 'got a warning (EDUPLICATEDEP) for duplicate dev/production dependencies') 45 46 s.close() 47 t.end() 48 }) 49 }) 50 }) 51}) 52