-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
validate-tree: Warn on deps in both dependencies and devDependencies
Fixes: npm#6725 Credit: @TedYav PR-URL: npm/npm#15772 Reviewed-By: @iarna
- Loading branch information
Showing
3 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ Ryan Emery <[email protected]> | |
Sam Mikes <[email protected]> | ||
Stephanie Snopek <[email protected]> | ||
Takaya Kobayashi <[email protected]> | ||
Ted Yavuzkurt <[email protected]> <[email protected]> | ||
Thomas Reggi <[email protected]> | ||
Timo Weiß <[email protected]> | ||
Tony <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
var fs = require('graceful-fs') | ||
var path = require('path') | ||
|
||
var mkdirp = require('mkdirp') | ||
var mr = require('npm-registry-mock') | ||
var osenv = require('osenv') | ||
var rimraf = require('rimraf') | ||
var test = require('tap').test | ||
|
||
var common = require('../common-tap.js') | ||
var npm = npm = require('../../') | ||
|
||
var pkg = path.resolve(__dirname, path.basename(__filename, '.js')) | ||
|
||
var json = { | ||
dependencies: { | ||
underscore: '1.5.1' | ||
}, | ||
devDependencies: { | ||
underscore: '1.3.1' | ||
} | ||
} | ||
|
||
test('setup', function (t) { | ||
t.comment('test for https://github.com/npm/npm/issues/6725') | ||
cleanup() | ||
mkdirp.sync(pkg) | ||
fs.writeFileSync( | ||
path.join(pkg, 'package.json'), | ||
JSON.stringify(json, null, 2) | ||
) | ||
process.chdir(pkg) | ||
console.dir(pkg) | ||
t.end() | ||
}) | ||
|
||
test('npm install with duplicate dependencies, different versions', function (t) { | ||
t.plan(1) | ||
mr({ port: common.port }, function (er, s) { | ||
var opts = { | ||
cache: path.resolve(pkg, 'cache'), | ||
registry: common.registry | ||
} | ||
|
||
npm.load(opts, function (err) { | ||
if (err) return t.fail(err) | ||
|
||
npm.install('.', function (err, additions, result) { | ||
if (err) return t.fail(err) | ||
|
||
var invalid = result.warnings.filter(function (warning) { return warning.code === 'EDUPLICATEDEP' }) | ||
t.is(invalid.length, 1, 'got a warning (EDUPLICATEDEP) for duplicate dev/production dependencies') | ||
|
||
s.close() | ||
t.end() | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
test('cleanup', function (t) { | ||
cleanup() | ||
t.end() | ||
}) | ||
|
||
function cleanup () { | ||
process.chdir(osenv.tmpdir()) | ||
rimraf.sync(pkg) | ||
} |