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: https://github.com/ggml-org/whisper.cpp/issues/3360
This commit is contained in:
Daniel Bevenius 2025-08-15 14:54:23 +02:00 committed by GitHub
parent 16c2924cb2
commit 040510a132
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View 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);