Skip to content

Commit ad99863

Browse files
macabeusHerringtonDarkholme
authored andcommitted
fix bundling for other archs
1 parent 7ef4c6c commit ad99863

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

packages/c/index.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
const path = require('node:path')
2-
const libPath = path.join(__dirname, 'parser.so')
2+
3+
function getNativePath() {
4+
if (process.platform === 'win32') {
5+
if (process.arch === 'x64') {
6+
return 'prebuilds/prebuild-Windows-X64/parser.so'
7+
}
8+
9+
throw new Error(`Unsupported architecture on Windows: ${process.arch}`)
10+
} else if (process.platform === 'darwin') {
11+
if (process.arch === 'arm64') {
12+
return 'prebuilds/prebuild-macOS-ARM64/parser.so';
13+
}
14+
15+
throw new Error(`Unsupported architecture on macOS: ${process.arch}`)
16+
} else if (process.platform === 'linux') {
17+
if (process.arch === 'x64') {
18+
return 'prebuilds/prebuild-Linux-X64/parser.so';
19+
}
20+
21+
throw new Error(`Unsupported architecture on Linux: ${process.arch}`)
22+
}
23+
24+
throw new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`)
25+
}
26+
27+
const libPath = path.join(__dirname, getNativePath())
328

429
module.exports = {
530
libraryPath: libPath,

0 commit comments

Comments
 (0)