@mcesystems/usb-device-listener 1.0.13 → 1.0.14

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +8 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcesystems/usb-device-listener",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "Native Windows USB device listener using PnP notifications without custom drivers",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { existsSync } from "node:fs";
1
2
  import { createRequire } from "node:module";
2
3
  import { dirname } from "node:path";
3
4
  import { fileURLToPath } from "node:url";
@@ -39,9 +40,14 @@ function loadNativeAddon(): NativeAddon {
39
40
  }
40
41
  let addon: NativeAddon;
41
42
  try {
42
- if (process.env.USB_DEVICE_LISTENER_ADDON_PATH) {
43
- addon = require("node-gyp-build")(process.env.USB_DEVICE_LISTENER_ADDON_PATH);
43
+ if (
44
+ process.env.USB_DEVICE_LISTENER_ADDON_PATH &&
45
+ existsSync(process.env.USB_DEVICE_LISTENER_ADDON_PATH)
46
+ ) {
47
+ console.log("Loading native addon from direct path", process.env.USB_DEVICE_LISTENER_ADDON_PATH);
48
+ addon = require(process.env.USB_DEVICE_LISTENER_ADDON_PATH);
44
49
  } else {
50
+ console.log("Loading native addon from node-gyp-build");
45
51
  addon = loadNativeAddon();
46
52
  }
47
53
  } catch (_error) {