Skip to content

Commit c64891f

Browse files
author
Mariusz Pasinski
committed
feat: add shortcut to isNodeApiModule()
If the path points to a file with a `.node` extension, then it must be a Node addon
1 parent 6725125 commit c64891f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/react-native-node-api-modules/src/node/path-utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ const packageNameCache = new Map<string, string>();
3131
* TODO: Consider checking for a specific platform extension.
3232
*/
3333
export function isNodeApiModule(modulePath: string): boolean {
34+
// HACK: Take a shortcut (if applicable)
35+
if (modulePath.endsWith('.node')) {
36+
try {
37+
fs.accessSync(modulePath);
38+
return true;
39+
} catch {}
40+
}
3441
const dir = path.dirname(modulePath);
3542
const baseName = path.basename(modulePath, ".node");
3643
let entries: string[];

0 commit comments

Comments
 (0)