dbx-native 0.2.1-beta → 0.2.2
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/dbx-native-0.2.2.tgz +0 -0
- package/index.js +23 -1
- package/package.json +1 -1
- package/dbx-native-0.2.1-beta.tgz +0 -0
|
Binary file
|
package/index.js
CHANGED
|
@@ -1,2 +1,24 @@
|
|
|
1
1
|
// DBX Native Node.js bindings
|
|
2
|
-
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
const isNode = f => f.endsWith('.node');
|
|
6
|
+
const nodes = fs.readdirSync(__dirname).filter(isNode);
|
|
7
|
+
|
|
8
|
+
if (nodes.length === 1) {
|
|
9
|
+
module.exports = require(path.join(__dirname, nodes[0]));
|
|
10
|
+
} else if (nodes.includes('dbx-native.node')) {
|
|
11
|
+
module.exports = require(path.join(__dirname, 'dbx-native.node'));
|
|
12
|
+
} else if (nodes.includes('index.node')) {
|
|
13
|
+
module.exports = require(path.join(__dirname, 'index.node'));
|
|
14
|
+
} else {
|
|
15
|
+
const { platform, arch } = process;
|
|
16
|
+
const load = (name) => {
|
|
17
|
+
try { return require(path.join(__dirname, name)); } catch (e) { return null; }
|
|
18
|
+
};
|
|
19
|
+
const mod = load(`dbx-native.${platform}-${arch}-gnu.node`) ||
|
|
20
|
+
load(`dbx-native.${platform}-${arch}-msvc.node`) ||
|
|
21
|
+
load(`dbx-native.${platform}-${arch}.node`);
|
|
22
|
+
if (!mod) throw new Error(`Could not find dbx-native binding for ${platform}-${arch}`);
|
|
23
|
+
module.exports = mod;
|
|
24
|
+
}
|
package/package.json
CHANGED
|
Binary file
|