@@ -16,7 +16,7 @@ module.exports = function (idealTree, args, next) {
1616 chain ( [
1717 [ hasMinimumFields , pkg ] ,
1818 [ checkSelf , idealTree , pkg , force ] ,
19- [ isInstallable , pkg ]
19+ [ isInstallable , idealTree , pkg ]
2020 ] , done )
2121 } , next )
2222}
@@ -31,17 +31,24 @@ function hasMinimumFields (pkg, cb) {
3131 }
3232}
3333
34- function setWarnings ( pkg , warn ) {
35- if ( ! pkg . warnings ) pkg . warnings = [ ]
36- if ( pkg . warnings . every ( i => (
34+ function setWarnings ( idealTree , warn ) {
35+ function top ( tree ) {
36+ if ( tree . parent ) return top ( tree . parent )
37+ return tree
38+ }
39+
40+ var topTree = top ( idealTree )
41+ if ( ! topTree . warnings ) topTree . warnings = [ ]
42+
43+ if ( topTree . warnings . every ( i => (
3744 i . code !== warn . code ||
3845 i . required !== warn . required ||
3946 i . pkgid !== warn . pkgid ) ) ) {
40- pkg . warnings . push ( warn )
47+ topTree . warnings . push ( warn )
4148 }
4249}
4350
44- var isInstallable = module . exports . isInstallable = function ( pkg , next ) {
51+ var isInstallable = module . exports . isInstallable = function ( idealTree , pkg , next ) {
4552 var force = npm . config . get ( 'force' )
4653 var nodeVersion = npm . config . get ( 'node-version' )
4754 if ( / - / . test ( nodeVersion ) ) {
@@ -52,7 +59,7 @@ var isInstallable = module.exports.isInstallable = function (pkg, next) {
5259 var strict = npm . config . get ( 'engine-strict' )
5360 checkEngine ( pkg , npm . version , nodeVersion , force , strict , iferr ( next , thenWarnEngineIssues ) )
5461 function thenWarnEngineIssues ( warn ) {
55- if ( warn ) setWarnings ( pkg , warn )
62+ if ( idealTree && warn ) setWarnings ( idealTree , warn )
5663 checkPlatform ( pkg , force , next )
5764 }
5865}
0 commit comments