1
0
mirror of https://github.com/keeweb/keeweb.git synced 2024-06-25 07:37:46 +02:00

loading native modules from updated desktop archives

This commit is contained in:
antelle 2020-06-01 16:45:18 +02:00
parent 21768b1b59
commit 360194c627
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C

View File

@ -731,10 +731,22 @@ function reportStartProfile() {
function reqNative(mod) { function reqNative(mod) {
const fileName = `${mod}-${process.platform}-${process.arch}.node`; 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') { if (mod === 'usb') {
usbBinding = initUsb(binding); usbBinding = initUsb(binding);
} }
return binding; return binding;
} }