Skip to content

Commit 0a795f0

Browse files
committed
Improve the search for Android .so files
1 parent 0d8cca1 commit 0a795f0

File tree

1 file changed

+10
-11
lines changed
  • packages/react-native-node-api-cmake/src

1 file changed

+10
-11
lines changed

packages/react-native-node-api-cmake/src/cli.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,16 @@ export const program = new Command("react-native-node-api-cmake")
245245
`Expected a directory at ${tripletOutputPath}`
246246
);
247247
// Expect binary file(s), either .node or .so
248-
const result = readdirSync(tripletOutputPath).map((file) => {
249-
const filePath = path.join(tripletOutputPath, file);
250-
if (file.endsWith(".so") || file.endsWith(".node")) {
251-
return filePath;
252-
} else {
253-
throw new Error(
254-
`Expected a .node or .so file, but found ${file}`
255-
);
256-
}
257-
});
258-
assert.equal(result.length, 1, "Expected exactly library file");
248+
const result = readdirSync(tripletOutputPath, {
249+
withFileTypes: true,
250+
})
251+
.filter(
252+
(dirent) =>
253+
dirent.isFile() &&
254+
(dirent.name.endsWith(".so") || dirent.name.endsWith(".node"))
255+
)
256+
.map((dirent) => path.join(dirent.parentPath, dirent.name));
257+
assert.equal(result.length, 1, "Expected exactly one library file");
259258
return [triplet, result[0]] as const;
260259
})
261260
) as Record<AndroidTriplet, string>;

0 commit comments

Comments
 (0)