Skip to content

Commit 040510a

Browse files
authored
node : add win platform check for require path (#3363)
This commit adds a check to the platform in use and adjust the path to the addon.node shared library. The motivation for this change is that on windows addon.node library is built into build\bin\Release and on linux into build/Release. Resolves: #3360
1 parent 16c2924 commit 040510a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

examples/addon.node/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
const path = require("path");
2-
const { whisper } = require(path.join(
3-
__dirname,
4-
"../../build/Release/addon.node"
5-
));
1+
const path = require('path');
2+
const os = require('os');
3+
4+
const isWindows = os.platform() === 'win32';
5+
const buildPath = isWindows ? "../../build/bin/Release/addon.node" : "../../build/Release/addon.node";
6+
7+
const { whisper } = require(path.join(__dirname, buildPath));
68
const { promisify } = require("util");
79

810
const whisperAsync = promisify(whisper);

0 commit comments

Comments
 (0)