danbev commited on
Commit
29b8653
·
unverified ·
1 Parent(s): e79709c

node : add win platform check for require path (#3363)

Browse files

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

Files changed (1) hide show
  1. examples/addon.node/index.js +7 -5
examples/addon.node/index.js CHANGED
@@ -1,8 +1,10 @@
1
- const path = require("path");
2
- const { whisper } = require(path.join(
3
- __dirname,
4
- "../../build/Release/addon.node"
5
- ));
 
 
6
  const { promisify } = require("util");
7
 
8
  const whisperAsync = promisify(whisper);
 
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));
8
  const { promisify } = require("util");
9
 
10
  const whisperAsync = promisify(whisper);