htn-tunnel 0.3.3 → 0.3.4

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/lib/install.js +10 -5
  2. package/package.json +1 -1
package/lib/install.js CHANGED
@@ -5,8 +5,8 @@ const os = require("os");
5
5
  const https = require("https");
6
6
  const { execSync } = require("child_process");
7
7
 
8
- // Binary version from GitHub Releases.
9
- const VERSION = "0.3.0";
8
+ // Binary version: read from package.json so it stays in sync with npm version.
9
+ const VERSION = require("../package.json").version;
10
10
  const REPO = "nhh0718/htn-tunnel";
11
11
 
12
12
  const platform = os.platform();
@@ -19,10 +19,15 @@ const archiveExt = platform === "win32" ? ".zip" : ".tar.gz";
19
19
  const binDir = path.join(__dirname, "..", "bin");
20
20
  const binPath = path.join(binDir, `htn-tunnel${ext}`);
21
21
 
22
- // Skip if binary exists and works.
22
+ // Skip only if binary exists AND matches expected version.
23
23
  if (fs.existsSync(binPath) && fs.statSync(binPath).size > 1000) {
24
- console.log("htn-tunnel: binary already installed.");
25
- process.exit(0);
24
+ try {
25
+ const out = execSync(`"${binPath}" --version`, { encoding: "utf8", timeout: 5000 }).trim();
26
+ if (out.includes(VERSION)) {
27
+ console.log(`htn-tunnel: v${VERSION} already installed.`);
28
+ process.exit(0);
29
+ }
30
+ } catch { /* version mismatch or error — re-download */ }
26
31
  }
27
32
 
28
33
  const archiveName = `htn-tunnel_${VERSION}_${goOS}_${goArch}${archiveExt}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "htn-tunnel",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Self-hosted tunnel client — expose localhost to the internet",
5
5
  "bin": {
6
6
  "htn-tunnel": "./bin/htn-tunnel.js"