@@ -657,57 +657,43 @@ export default class Package {
657657
658658 outdatedDependencies ||= { } ;
659659
660- const linkedDependencies = await this . #getLinkedDependencies( ) ,
661- index = { } ;
662-
663- // index dependencies
660+ // prepare outdated dependencies
664661 for ( const name in outdatedDependencies ) {
665- let dependencies ;
666-
667- if ( Array . isArray ( outdatedDependencies [ name ] ) ) {
668- dependencies = outdatedDependencies [ name ] ;
669- }
670- else {
671- dependencies = [ outdatedDependencies [ name ] ] ;
662+ if ( ! Array . isArray ( outdatedDependencies [ name ] ) ) {
663+ outdatedDependencies [ name ] = [ outdatedDependencies [ name ] ] ;
672664 }
673665
674- for ( const dependency of dependencies ) {
675-
676- // not-installed dependency
677- if ( ! dependency . location ) {
678- dependency . location = path . join ( this . root , "node_modules" , name ) ;
679- }
666+ for ( const dependency of outdatedDependencies [ name ] ) {
667+ dependency . name = name ;
668+ }
669+ }
680670
681- if ( index [ dependency . location ] ) {
671+ const linkedDependencies = await this . #getLinkedDependencies( ) ,
672+ dependencies = [
682673
683- // use minimal wanted version
684- if ( new SemanticVersion ( dependency . wanted ) . lt ( index [ dependency . location ] . wanted ) ) {
685- index [ dependency . location ] . wanted = dependency . wanted ;
686- }
687- }
688- else {
689- index [ dependency . location ] = {
690- name,
691- "current" : dependency . current ,
692- "wanted" : dependency . wanted ,
693- "latest" : dependency . latest ,
694- "location" : dependency . location ,
695- "dependent" : new Set ( ) ,
696- "topLevel" : this . dependencies . has ( name ) && dependency . location === path . join ( this . root , "node_modules" , name ) ,
697- } ;
698- }
674+ //
675+ ...Object . values ( linkedDependencies ) ,
676+ ...Object . values ( outdatedDependencies ) ,
677+ ] ,
678+ index = { } ;
699679
700- index [ dependency . location ] . dependent . add ( dependency . dependent ) ;
680+ // index dependencies
681+ for ( const dependency of dependencies ) {
682+ const id = `${ dependency . name } /${ dependency . location } /${ dependency . current } /${ dependency . wanted } ` ;
683+
684+ if ( ! index [ id ] ) {
685+ index [ id ] = {
686+ "name" : dependency . name ,
687+ "current" : dependency . current ,
688+ "wanted" : dependency . wanted ,
689+ "latest" : dependency . latest ,
690+ "dependent" : new Set ( ) ,
691+ "topLevel" : this . dependencies . has ( dependency . name ) && dependency . location === path . join ( this . root , "node_modules" , name ) ,
692+ } ;
701693 }
702- }
703694
704- // add not-installed / linked deps
705- for ( const dependency of linkedDependencies . values ( ) ) {
706- if ( index [ dependency . location ] ) {
707- index [ dependency . location ] . linked = dependency . linked ;
708- }
709- else {
710- index [ dependency . location ] = dependency ;
695+ if ( dependency . dependent ) {
696+ index [ id ] . dependent . add ( dependency . dependent ) ;
711697 }
712698 }
713699
0 commit comments