@@ -808,3 +808,113 @@ t.same(bundledEdge.explain(), {
808
808
bundled : true ,
809
809
from : bundleParent . explain ( ) ,
810
810
} , 'bundled edge.explain as expected' )
811
+
812
+ t . test ( 'shrinkwrapped and bundled deps are not overridden and remain valid' , ( t ) => {
813
+ const overrides = new OverrideSet ( {
814
+ overrides : {
815
+ bar : '^2.0.0' ,
816
+ } ,
817
+ } )
818
+
819
+ const root = {
820
+ name : 'root' ,
821
+ packageName : 'root' ,
822
+ edgesOut : new Map ( ) ,
823
+ edgesIn : new Set ( ) ,
824
+ explain : ( ) => 'root node explanation' ,
825
+ package : {
826
+ name : 'root' ,
827
+ version : '1.2.3' ,
828
+ dependencies : {
829
+ foo : '^1.0.0' ,
830
+ } ,
831
+ overrides : {
832
+ bar : '^2.0.0' ,
833
+ } ,
834
+ } ,
835
+ get version ( ) {
836
+ return this . package . version
837
+ } ,
838
+ isTop : true ,
839
+ parent : null ,
840
+ overrides,
841
+ resolve ( n ) {
842
+ return n === 'foo' ? foo : null
843
+ } ,
844
+ addEdgeOut ( edge ) {
845
+ this . edgesOut . set ( edge . name , edge )
846
+ } ,
847
+ addEdgeIn ( edge ) {
848
+ this . edgesIn . add ( edge )
849
+ } ,
850
+ }
851
+
852
+ const foo = {
853
+ name : 'foo' ,
854
+ packageName : 'foo' ,
855
+ edgesOut : new Map ( ) ,
856
+ edgesIn : new Set ( ) ,
857
+ explain : ( ) => 'foo node explanation' ,
858
+ hasShrinkwrap : true ,
859
+ package : {
860
+ name : 'foo' ,
861
+ version : '1.2.3' ,
862
+ dependencies : {
863
+ bar : '^1.0.0' ,
864
+ } ,
865
+ } ,
866
+ get version ( ) {
867
+ return this . package . version
868
+ } ,
869
+ parent : root ,
870
+ resolve ( n ) {
871
+ return n === 'bar' ? bar : this . parent . resolve ( n )
872
+ } ,
873
+ addEdgeOut ( edge ) {
874
+ this . edgesOut . set ( edge . name , edge )
875
+ } ,
876
+ addEdgeIn ( edge ) {
877
+ this . edgesIn . add ( edge )
878
+ } ,
879
+ }
880
+ foo . overrides = overrides . getNodeRule ( foo )
881
+
882
+ const bar = {
883
+ name : 'bar' ,
884
+ packageName : 'bar' ,
885
+ edgesOut : new Map ( ) ,
886
+ edgesIn : new Set ( ) ,
887
+ explain : ( ) => 'bar node explanation' ,
888
+ inShrinkwrap : true ,
889
+ package : {
890
+ name : 'bar' ,
891
+ version : '1.2.3' ,
892
+ dependencies : { } ,
893
+ } ,
894
+ get version ( ) {
895
+ return this . package . version
896
+ } ,
897
+ parent : foo ,
898
+ resolve ( n ) {
899
+ return this . parent . resolve ( n )
900
+ } ,
901
+ addEdgeOut ( edge ) {
902
+ this . edgesOut . set ( edge . name , edge )
903
+ } ,
904
+ addEdgeIn ( edge ) {
905
+ this . edgesIn . add ( edge )
906
+ } ,
907
+ }
908
+ bar . overrides = foo . overrides . getNodeRule ( bar )
909
+
910
+ const edge = new Edge ( {
911
+ from : foo ,
912
+ type : 'prod' ,
913
+ spec : '^1.0.0' ,
914
+ name : 'bar' ,
915
+ overrides : overrides . getEdgeRule ( { name : 'bar' , spec : '^1.0.0' } ) ,
916
+ } )
917
+
918
+ t . ok ( edge . valid , 'edge is valid' )
919
+ t . end ( )
920
+ } )
0 commit comments