File tree 1 file changed +29
-1
lines changed
1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -890,7 +890,35 @@ namespace Private {
890
890
add ( id ) ;
891
891
}
892
892
893
- const sorted = topologicSort ( edges ) ;
893
+ // Filter edges
894
+ // - Get all packages that dependent on the package to be deactivated
895
+ const newEdges = edges . filter ( edge => edge [ 1 ] === id ) ;
896
+ let oldSize = 0 ;
897
+ while ( newEdges . length > oldSize ) {
898
+ const previousSize = newEdges . length ;
899
+ // Get all packages that dependent on packages that will be deactivated
900
+ const packagesOfInterest = newEdges
901
+ . map ( edge => edge [ 0 ] )
902
+ . reduce < string [ ] > ( ( agg , value ) => {
903
+ if ( agg . indexOf ( value ) == - 1 ) {
904
+ agg . push ( value ) ;
905
+ }
906
+ return agg ;
907
+ } , [ ] ) ;
908
+ for ( const poi of packagesOfInterest ) {
909
+ edges
910
+ . filter ( edge => edge [ 1 ] === poi )
911
+ . forEach ( edge => {
912
+ // We check it is not already included to deal with circular dependencies
913
+ if ( newEdges . indexOf ( edge ) == - 1 ) {
914
+ newEdges . push ( edge ) ;
915
+ }
916
+ } ) ;
917
+ }
918
+ oldSize = previousSize ;
919
+ }
920
+
921
+ const sorted = topologicSort ( newEdges ) ;
894
922
const index = findIndex ( sorted , candidate => candidate === id ) ;
895
923
896
924
if ( index === - 1 ) {
You can’t perform that action at this time.
0 commit comments