1- import { isNonEmptyString , isObject } from 'expect-more' ;
1+ import { isNonEmptyArray , isNonEmptyString , isObject } from 'expect-more' ;
22import minimatch from 'minimatch' ;
33import type {
44 DependencyType ,
@@ -52,8 +52,8 @@ export function getInstances(
5252 if ( ! isNonEmptyString ( version ) ) continue ;
5353 const instance = { dependencyType, name, version, wrapper } ;
5454 allInstances . all . push ( instance ) ;
55- groupInstancesBy ( 'semverGroups' , pkgName , instance ) ;
56- groupInstancesBy ( 'versionGroups' , pkgName , instance ) ;
55+ groupInstancesBy ( 'semverGroups' , dependencyType , pkgName , instance ) ;
56+ groupInstancesBy ( 'versionGroups' , dependencyType , pkgName , instance ) ;
5757 }
5858 }
5959 }
@@ -68,6 +68,7 @@ export function getInstances(
6868
6969 function groupInstancesBy (
7070 groupName : 'semverGroups' | 'versionGroups' ,
71+ dependencyType : DependencyType ,
7172 pkgName : string ,
7273 instance : Instance ,
7374 ) : void {
@@ -76,7 +77,7 @@ export function getInstances(
7677 if ( ! groups . length ) return ;
7778 for ( const i in groups ) {
7879 const group = groups [ i ] ;
79- if ( matchesGroup ( pkgName , name , group ) ) {
80+ if ( matchesGroup ( dependencyType , pkgName , name , group ) ) {
8081 if ( ! group . instancesByName [ name ] ) {
8182 group . instancesByName [ name ] = [ ] ;
8283 }
@@ -89,11 +90,14 @@ export function getInstances(
8990 }
9091
9192 function matchesGroup (
93+ dependencyType : DependencyType ,
9294 pkgName : string ,
9395 dependencyName : string ,
9496 group : SemverGroup | VersionGroup ,
9597 ) : boolean {
9698 return (
99+ ( ! isNonEmptyArray ( group . dependencyTypes ) ||
100+ group . dependencyTypes . includes ( dependencyType ) ) &&
97101 group . packages . some ( ( pattern ) => minimatch ( pkgName , pattern ) ) &&
98102 group . dependencies . some ( ( pattern ) => minimatch ( dependencyName , pattern ) )
99103 ) ;
0 commit comments