Skip to content

Commit cb1bc56

Browse files
committed
node : add win platform check for require path
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: ggml-org#3360
1 parent 0becabc commit cb1bc56

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)