htn-tunnel 0.2.1 → 0.2.3
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.
- package/lib/install.js +6 -3
- package/package.json +1 -1
package/lib/install.js
CHANGED
|
@@ -5,7 +5,8 @@ const os = require("os");
|
|
|
5
5
|
const https = require("https");
|
|
6
6
|
const { execSync } = require("child_process");
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// Binary version from GitHub Releases (may differ from npm package version).
|
|
9
|
+
const VERSION = "0.2.0";
|
|
9
10
|
const REPO = "nhh0718/htn-tunnel";
|
|
10
11
|
|
|
11
12
|
const platform = os.platform(); // darwin, linux, win32
|
|
@@ -88,7 +89,8 @@ function extractTarGz(gzData, filename, dest) {
|
|
|
88
89
|
const sizeStr = header.toString("utf8", 124, 136).replace(/\0/g, "").trim();
|
|
89
90
|
const size = parseInt(sizeStr, 8) || 0;
|
|
90
91
|
offset += 512;
|
|
91
|
-
|
|
92
|
+
const baseName = name.split("/").pop();
|
|
93
|
+
if (baseName === filename) {
|
|
92
94
|
fs.writeFileSync(dest, tarData.subarray(offset, offset + size));
|
|
93
95
|
return;
|
|
94
96
|
}
|
|
@@ -107,7 +109,8 @@ function extractZip(zipData, filename, dest) {
|
|
|
107
109
|
const extraLen = zipData.readUInt16LE(offset + 28);
|
|
108
110
|
const name = zipData.toString("utf8", offset + 30, offset + 30 + nameLen);
|
|
109
111
|
const dataStart = offset + 30 + nameLen + extraLen;
|
|
110
|
-
|
|
112
|
+
const baseName = name.split("/").pop();
|
|
113
|
+
if (baseName === filename) {
|
|
111
114
|
if (compMethod === 0) {
|
|
112
115
|
fs.writeFileSync(dest, zipData.subarray(dataStart, dataStart + compSize));
|
|
113
116
|
} else {
|