overlapdev 1.4.2 → 1.4.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/package.json +1 -1
- package/scripts/postinstall.js +5 -24
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
* Postinstall script for the overlapdev npm package.
|
|
4
4
|
* Downloads the correct pre-compiled binary for the user's platform.
|
|
5
5
|
*/
|
|
6
|
-
import { existsSync, mkdirSync, chmodSync, createWriteStream } from "fs";
|
|
6
|
+
import { existsSync, mkdirSync, chmodSync, createWriteStream, readFileSync } from "fs";
|
|
7
7
|
import { join, dirname } from "path";
|
|
8
8
|
import { fileURLToPath } from "url";
|
|
9
9
|
import https from "https";
|
|
10
10
|
|
|
11
11
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
12
|
const REPO = "overlapcode/overlap-tracer";
|
|
13
|
+
const PKG = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf8"));
|
|
13
14
|
const BIN_DIR = join(__dirname, "..", "bin");
|
|
14
15
|
const BINARY_PATH = join(BIN_DIR, process.platform === "win32" ? "overlap.exe" : "overlap");
|
|
15
16
|
|
|
@@ -48,21 +49,8 @@ function httpsGet(url) {
|
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return new Promise((resolve, reject) => {
|
|
54
|
-
let data = "";
|
|
55
|
-
res.on("data", (chunk) => (data += chunk));
|
|
56
|
-
res.on("end", () => {
|
|
57
|
-
try {
|
|
58
|
-
const json = JSON.parse(data);
|
|
59
|
-
resolve(json.tag_name);
|
|
60
|
-
} catch (e) {
|
|
61
|
-
reject(e);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
res.on("error", reject);
|
|
65
|
-
});
|
|
52
|
+
function getVersion() {
|
|
53
|
+
return `v${PKG.version}`;
|
|
66
54
|
}
|
|
67
55
|
|
|
68
56
|
async function download(url, dest) {
|
|
@@ -84,14 +72,7 @@ async function main() {
|
|
|
84
72
|
const target = getPlatformTarget();
|
|
85
73
|
console.log(`[overlap] Downloading binary for ${process.platform}-${process.arch}...`);
|
|
86
74
|
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
|
-
version = await getLatestVersion();
|
|
90
|
-
} catch {
|
|
91
|
-
console.warn("[overlap] Could not determine latest version. Skipping binary download.");
|
|
92
|
-
console.warn("[overlap] You can download manually from: https://github.com/overlapcode/overlap-tracer/releases");
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
75
|
+
const version = getVersion();
|
|
95
76
|
|
|
96
77
|
const url = `https://github.com/${REPO}/releases/download/${version}/${target}`;
|
|
97
78
|
|