@@ -541,6 +541,52 @@ describe("findNodeApiModulePathsByDependency", () => {
541541 } ) ;
542542 } ) ;
543543
544+ it ( "should find Node-API paths by dependency in root package.json configuration with incorrect dependency configuration (excluding certain packages)" , async ( context ) => {
545+ const packagesNames = [ "lib-a" , "lib-b" , "lib-c" , "lib-d" ] ;
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 : {
556+ dependencies : [ "lib-e" ] ,
557+ } ,
558+ } ,
559+ } ) ,
560+ ...Object . fromEntries (
561+ packagesNames . map ( ( packageName ) => [
562+ `app/node_modules/${ packageName } ` ,
563+ {
564+ "package.json" : JSON . stringify ( {
565+ name : packageName ,
566+ main : "index.js" ,
567+ } ) ,
568+ "index.js" : "" ,
569+ "addon.apple.node/react-native-node-api-module" : "" ,
570+ } ,
571+ ] ) ,
572+ ) ,
573+ } ) ;
574+
575+ // shouldn't find lib-e
576+ const result = await findNodeApiModulePathsByDependency ( {
577+ fromPath : path . join ( tempDir , "app" ) ,
578+ platform : "apple" ,
579+ includeSelf : false ,
580+ excludePackages : [ "lib-a" ] ,
581+ } ) ;
582+ assert . deepEqual ( result , {
583+ "lib-b" : {
584+ path : path . join ( tempDir , "app/node_modules/lib-b" ) ,
585+ modulePaths : [ "addon.apple.node" ] ,
586+ } ,
587+ } ) ;
588+ } ) ;
589+
544590 it ( "should find Node-API paths by dependency in child modules configuration (excluding certain packages)" , async ( context ) => {
545591 const packagesNames = [ "lib-a" , "lib-b" , "lib-c" , "lib-d" , "lib-e" ] ;
546592 const tempDir = setupTempDirectory ( context , {
0 commit comments