diff --git a/package.json b/package.json index 52df7b8..035f865 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,9 @@ "engines": { "node": ">=16.0.0" }, + "binary": { + "napi_versions": [8] + }, "scripts": { "install": "cmake-js compile", "build": "cmake-js rebuild", diff --git a/src/addons.ts b/src/addons.ts index 251d3ed..7fe4c74 100644 --- a/src/addons.ts +++ b/src/addons.ts @@ -1,8 +1,10 @@ import path from "node:path"; import fs from "node:fs/promises"; - -const __dirname = import.meta.dirname || path.dirname((await import("node:url")).fileURLToPath(import.meta.url)); -export const projectRoot: string = !process["resourcesPath"] ? path.resolve(__dirname, "..") : process["resourcesPath"]; +const __dirname = import.meta.dirname || path.dirname((await import("node:url")).fileURLToPath(import.meta.url)); // Solve current __dirname in ESM module +export const projectRoot = path.resolve(__dirname, ".."); +if (__dirname.includes(".asar")) { + console.warn("Check if addon nothing includes in .asar file") +} declare global { namespace NodeJS { @@ -43,11 +45,11 @@ export async function LoadAddon(addonFile: string, exports?: Record; }>("wg", { - WIN32DLLPATH: path.resolve(projectRoot, "addon/win", (process.arch === "x64" && "amd64") || (process.arch === "ia32" && "x86") || process.arch, "wireguard.dll") + WIN32DLLPATH: !process.env.WGWIN32DLL ? path.resolve(projectRoot, "addon/win", (process.arch === "x64" && "amd64") || (process.arch === "ia32" && "x86") || process.arch, "wireguard.dll") : path.resolve(process.env.WGWIN32DLL), }); export const {