-
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.
Fix npm#10727 - Consider devDependencies when deciding whether to hoi…
…st a package Fixes several issues that were causing devDependencies to clobber transitive dependencies. When prod & dev dependencies are installed in the same batch, both groups of dependencies are now processed together so that overlapping transitive dependencies are properly deduplicated. Fixes npm#10727 npm#11062 npm#12654 npm#10277 npm#11766 npm#11043
- Loading branch information
Andrew Schmadel
committed
May 23, 2016
1 parent
5e2fec7
commit 4e990d0
Showing
4 changed files
with
93 additions
and
5 deletions.
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
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
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,58 @@ | ||
'use strict' | ||
var test = require('tap').test | ||
var requireInject = require('require-inject') | ||
|
||
// we're just mocking to avoid having to call `npm.load` | ||
var deps = requireInject('../../lib/install/deps.js', { | ||
'../../lib/npm.js': { | ||
config: { | ||
get: function (val) { return (val === 'global-style' || val === 'legacy-bundling') ? false : 'mock' } | ||
} | ||
} | ||
}) | ||
|
||
var earliestInstallable = deps.earliestInstallable | ||
|
||
test('earliestInstallable should consider devDependencies', function (t) { | ||
var dep1 = { | ||
children: [], | ||
package: { | ||
name: 'dep1', | ||
dependencies: { dep2: '2.0.0' } | ||
} | ||
} | ||
|
||
// a library required by the base package | ||
var dep2 = { | ||
package: { | ||
name: 'dep2', | ||
version: '1.0.0' | ||
} | ||
} | ||
|
||
// an incompatible verson of dep2. required by dep1 | ||
var dep2a = { | ||
package: { | ||
name: 'dep2', | ||
version: '2.0.0' | ||
}, | ||
parent: dep1 | ||
} | ||
|
||
var pkg = { | ||
children: [dep1], | ||
package: { | ||
name: 'pkg', | ||
dependencies: { dep1: '1.0.0' }, | ||
devDependencies: { dep2: '1.0.0' } | ||
} | ||
} | ||
|
||
dep1.parent = pkg | ||
dep2a.parent = dep1 | ||
dep2.parent = pkg | ||
|
||
var earliest = earliestInstallable(dep1, dep1, dep2a.package) | ||
t.isDeeply(earliest, dep1, 'should hoist package when an incompatible devDependency is present') | ||
t.end() | ||
}) |