@acentera/node 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +15 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
const os = require('os');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
2
5
|
|
|
3
6
|
function loadLibrary() {
|
|
4
7
|
const arch = os.arch();
|
|
@@ -7,22 +10,29 @@ function loadLibrary() {
|
|
|
7
10
|
let libName;
|
|
8
11
|
if (platform === 'darwin') {
|
|
9
12
|
if (arch === 'x64') {
|
|
10
|
-
libName = '
|
|
13
|
+
libName = 'acentera.dylib.x86';
|
|
11
14
|
} else {
|
|
12
|
-
libName = '
|
|
15
|
+
libName = 'acentera.dylib.arm64';
|
|
13
16
|
}
|
|
14
17
|
} else if (platform === 'linux') {
|
|
15
18
|
if (arch === 'x64') {
|
|
16
|
-
libName = '
|
|
19
|
+
libName = 'acentera';
|
|
17
20
|
} else {
|
|
18
|
-
libName = '
|
|
21
|
+
libName = 'acentera.arm64';
|
|
19
22
|
}
|
|
20
23
|
} else {
|
|
21
24
|
throw new Error('Unsupported platform');
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
libName += '.node';
|
|
25
|
-
|
|
28
|
+
// The path to the file you want to check
|
|
29
|
+
const filePath = path.join(__dirname, libName);
|
|
30
|
+
|
|
31
|
+
if (fs.existsSync(filePath)) {
|
|
32
|
+
return require(filePath);
|
|
33
|
+
} else {
|
|
34
|
+
return require(libName);
|
|
35
|
+
}
|
|
26
36
|
}
|
|
27
37
|
|
|
28
38
|
module.exports = loadLibrary();
|