bluetooth-serial-port 3.0.4-beta.11 → 3.0.4-beta.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bluetooth-serial-port",
3
- "version": "3.0.4-beta.11",
3
+ "version": "3.0.4-beta.12",
4
4
  "description": "Bluetooth serial port communication for Node.js",
5
5
  "author": "Eelco Cramer <eelco@hailendal.org>",
6
6
  "keywords": [
@@ -34,8 +34,7 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "nan": "^2.28.0",
37
- "node-gyp-build": "^4.8.4",
38
- "stable": "^0.1.8"
37
+ "node-gyp-build": "^4.8.4"
39
38
  },
40
39
  "devDependencies": {},
41
40
  "optionalDependencies": {
@@ -46,7 +45,7 @@
46
45
  "npm": ">= 8.x"
47
46
  },
48
47
  "scripts": {
49
- "install": "node-gyp-build",
48
+ "install": "node scripts/install-native.js",
50
49
  "install-release": "node-gyp configure build",
51
50
  "install-debug": "node-gyp configure build --debug",
52
51
  "prebuild": "node scripts/create-prebuilds.js --strip",
@@ -0,0 +1,45 @@
1
+ // scripts/install-native.js
2
+ 'use strict';
3
+
4
+ var cp = require('child_process');
5
+ var fs = require('fs');
6
+ var path = require('path');
7
+
8
+ var rootDir = path.join(__dirname, '..');
9
+ var abi = process.versions.modules;
10
+ var platform = process.platform;
11
+ var arch = process.arch;
12
+ var prebuildDir = path.join(rootDir, 'prebuilds', platform + '-' + arch);
13
+
14
+ var moduleNames = ['BluetoothSerialPort'];
15
+ if (platform === 'linux') {
16
+ moduleNames.push('BluetoothSerialPortServer');
17
+ }
18
+
19
+ function hasAllPrebuilds() {
20
+ for (var i = 0; i < moduleNames.length; i++) {
21
+ var filename = moduleNames[i] + '.abi' + abi + '.node';
22
+ if (!fs.existsSync(path.join(prebuildDir, filename))) {
23
+ return false;
24
+ }
25
+ }
26
+ return true;
27
+ }
28
+
29
+ if (hasAllPrebuilds()) {
30
+ console.log('Using bundled prebuilds from ' + path.relative(rootDir, prebuildDir));
31
+ process.exit(0);
32
+ }
33
+
34
+ console.log('No matching prebuilds found for ' + platform + '-' + arch + ' abi' + abi + '; building from source...');
35
+ var bin = process.platform === 'win32' ? 'node-gyp.cmd' : 'node-gyp';
36
+ var result = cp.spawnSync(bin, ['rebuild'], {
37
+ stdio: 'inherit',
38
+ shell: process.platform === 'win32',
39
+ windowsHide: true
40
+ });
41
+
42
+ if (result.error) {
43
+ throw result.error;
44
+ }
45
+ process.exit(result.status || 0);