From 91333c1a3efb69a209bb0f9827680e1edada2a84 Mon Sep 17 00:00:00 2001 From: xenos <66328734+xenos1337@users.noreply.github.com> Date: Sat, 29 Nov 2025 00:06:55 +0100 Subject: [PATCH] refactor(version): read LOCAL_VERSION from package.json dynamically --- index.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index a48cdbe..b25950f 100644 --- a/index.js +++ b/index.js @@ -8,10 +8,6 @@ import readline from "readline"; import https from "https"; import { fileURLToPath } from "url"; -// Version info -const LOCAL_VERSION = "2.0.8"; -const GITHUB_REPO = "xenos1337/httptoolkit-patcher"; - const isWin = process.platform === "win32"; const isMac = process.platform === "darwin"; const isLinux = process.platform === "linux"; @@ -27,6 +23,18 @@ const __filename = (() => { return fileURLToPath(import.meta.url); })(); +// Version info - read from package.json +const GITHUB_REPO = "xenos1337/httptoolkit-patcher"; +const LOCAL_VERSION = (() => { + try { + const packageJsonPath = path.join(path.dirname(__filename), "package.json"); + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8")); + return packageJson.version || "0.0.0"; + } catch { + return "0.0.0"; + } +})(); + // Check if running with elevated privileges function isElevated() { if (isWin) {