mirror of https://github.com/keeweb/keeweb
loading native modules from updated desktop archives
parent
21768b1b59
commit
360194c627
|
@ -731,10 +731,22 @@ function reportStartProfile() {
|
|||
|
||||
function reqNative(mod) {
|
||||
const fileName = `${mod}-${process.platform}-${process.arch}.node`;
|
||||
const binding = require(`@keeweb/keeweb-native-modules/${fileName}`);
|
||||
|
||||
const mainAsarPath = process.mainModule.path;
|
||||
const latestAsarPath = __dirname;
|
||||
const pathInsideAsar = `node_modules/@keeweb/keeweb-native-modules/${fileName}`;
|
||||
|
||||
let fullPath = path.join(latestAsarPath, pathInsideAsar);
|
||||
if (!fs.existsSync(fullPath)) {
|
||||
fullPath = path.join(mainAsarPath, pathInsideAsar);
|
||||
}
|
||||
|
||||
const binding = require(fullPath);
|
||||
|
||||
if (mod === 'usb') {
|
||||
usbBinding = initUsb(binding);
|
||||
}
|
||||
|
||||
return binding;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue