Skip to content

Commit 105268e

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 6f0ea57 commit 105268e

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
@@ -32,6 +32,13 @@ const packageNameCache = new Map<string, string>();
3232
* TODO: Consider checking for a specific platform extension.
3333
*/
3434
export function isNodeApiModule(modulePath: string): boolean {
35+
// HACK: Take a shortcut (if applicable)
36+
if (modulePath.endsWith('.node')) {
37+
try {
38+
fs.accessSync(modulePath);
39+
return true;
40+
} catch {}
41+
}
3542
const dir = path.dirname(modulePath);
3643
const baseName = path.basename(modulePath, ".node");
3744
let entries: string[];

0 commit comments

Comments
 (0)