]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
node : add win platform check for require path (#3363)
authorDaniel Bevenius <redacted>
Fri, 15 Aug 2025 12:54:23 +0000 (14:54 +0200)
committerGitHub <redacted>
Fri, 15 Aug 2025 12:54:23 +0000 (14:54 +0200)
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: https://github.com/ggml-org/whisper.cpp/issues/3360

examples/addon.node/index.js

index 9324d6fa5487e0a5dea4b06608ef66daba10e6c8..2e4ed610b66db138bf19e3bb961715f7d5da90e1 100644 (file)
@@ -1,8 +1,10 @@
-const path = require("path");
-const { whisper } = require(path.join(
-  __dirname,
-  "../../build/Release/addon.node"
-));
+const path = require('path');
+const os = require('os');
+
+const isWindows = os.platform() === 'win32';
+const buildPath = isWindows ? "../../build/bin/Release/addon.node" : "../../build/Release/addon.node";
+
+const { whisper } = require(path.join(__dirname, buildPath));
 const { promisify } = require("util");
 
 const whisperAsync = promisify(whisper);