Skip to content

Commit e40dc0d

Browse files
committed
done
1 parent 8ad4d34 commit e40dc0d

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

packages/host/src/node/path-utils.test.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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, {

packages/host/src/node/path-utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ export function findPackageDependencyPaths(
376376

377377
const root = resolvePackageRoot(requireFromRoot, name);
378378
if (!root) {
379+
console.warn(`Cannot find package root from ${fromPath} for ${name}`);
379380
continue;
380381
}
381382

0 commit comments

Comments
 (0)