@@ -541,6 +541,50 @@ describe("findNodeApiModulePathsByDependency", () => {
541541 } ) ;
542542 } ) ;
543543
544+ it ( "should find Node-API paths by dependency in root package.json with bad configuration (excluding certain packages)" , async ( context ) => {
545+ const packagesNames = [ "lib-a" , "lib-b" , "lib-c" , "lib-d" , "lib-e" ] ;
546+ const tempDir = setupTempDirectory ( context , {
547+ "app/package.json" : JSON . stringify ( {
548+ name : "app" ,
549+ dependencies : Object . fromEntries (
550+ packagesNames
551+ . slice ( 0 , 2 )
552+ . map ( ( packageName ) => [ packageName , "^1.0.0" ] ) ,
553+ ) ,
554+ reactNativeNodeApi : {
555+ scan : "lib-e" ,
556+ } ,
557+ } ) ,
558+ ...Object . fromEntries (
559+ packagesNames . map ( ( packageName ) => [
560+ `app/node_modules/${ packageName } ` ,
561+ {
562+ "package.json" : JSON . stringify ( {
563+ name : packageName ,
564+ main : "index.js" ,
565+ } ) ,
566+ "index.js" : "" ,
567+ "addon.apple.node/react-native-node-api-module" : "" ,
568+ } ,
569+ ] ) ,
570+ ) ,
571+ } ) ;
572+
573+ // shouldn't drop error
574+ const result = await findNodeApiModulePathsByDependency ( {
575+ fromPath : path . join ( tempDir , "app" ) ,
576+ platform : "apple" ,
577+ includeSelf : false ,
578+ excludePackages : [ "lib-a" ] ,
579+ } ) ;
580+ assert . deepEqual ( result , {
581+ "lib-b" : {
582+ path : path . join ( tempDir , "app/node_modules/lib-b" ) ,
583+ modulePaths : [ "addon.apple.node" ] ,
584+ } ,
585+ } ) ;
586+ } ) ;
587+
544588 it ( "should find Node-API paths by dependency in root package.json configuration with incorrect dependency configuration (excluding certain packages)" , async ( context ) => {
545589 const packagesNames = [ "lib-a" , "lib-b" , "lib-c" , "lib-d" ] ;
546590 const tempDir = setupTempDirectory ( context , {
@@ -706,7 +750,7 @@ describe("findNodeApiModulePathsByDependency", () => {
706750 packagesNames . slice ( 1 ) . map ( ( packageName , i ) => {
707751 // if even then i-1
708752 // if not even then i+1
709- const dependencyIndex = i + ( ( i % 2 ) * 2 - 1 )
753+ const dependencyIndex = i + ( ( i % 2 ) * 2 - 1 ) ;
710754
711755 return [
712756 `app/node_modules/${ packageName } ` ,
0 commit comments