@sachinthapa572/fast 0.1.4-rc → 0.1.5-rc
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/install.js +29 -18
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -16,9 +16,12 @@ const OS_MAP = { win32: "Windows", darwin: "Darwin", linux: "Linux" };
|
|
|
16
16
|
const ARCH_MAP = { x64: "x86_64", arm64: "aarch64" };
|
|
17
17
|
const EXT_MAP = { win32: ".zip", darwin: ".tar.gz", linux: ".tar.gz" };
|
|
18
18
|
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
const
|
|
19
|
+
// Default: download from GitHub Releases. Override via FAST_DOWNLOAD_URL env var.
|
|
20
|
+
const GH_OWNER = "sachinthapa572";
|
|
21
|
+
const GH_REPO = "fast-release";
|
|
22
|
+
const DOWNLOAD_BASE =
|
|
23
|
+
process.env.FAST_DOWNLOAD_URL ||
|
|
24
|
+
`https://github.com/${GH_OWNER}/${GH_REPO}/releases/download`;
|
|
22
25
|
|
|
23
26
|
function downloadUrl() {
|
|
24
27
|
const os = OS_MAP[platform()];
|
|
@@ -35,20 +38,28 @@ function downloadUrl() {
|
|
|
35
38
|
function download(url, dest) {
|
|
36
39
|
return new Promise((resolve, reject) => {
|
|
37
40
|
const mod = url.startsWith("https") ? https : http;
|
|
38
|
-
mod
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
mod
|
|
42
|
+
.get(url, (res) => {
|
|
43
|
+
if (
|
|
44
|
+
res.statusCode >= 300 &&
|
|
45
|
+
res.statusCode < 400 &&
|
|
46
|
+
res.headers.location
|
|
47
|
+
) {
|
|
48
|
+
download(res.headers.location, dest).then(resolve).catch(reject);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (res.statusCode !== 200) {
|
|
52
|
+
reject(
|
|
53
|
+
new Error(`Download failed: HTTP ${res.statusCode} for ${url}`),
|
|
54
|
+
);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const file = createWriteStream(dest);
|
|
58
|
+
res.pipe(file);
|
|
59
|
+
file.on("finish", () => file.close(resolve));
|
|
60
|
+
file.on("error", reject);
|
|
61
|
+
})
|
|
62
|
+
.on("error", reject);
|
|
52
63
|
});
|
|
53
64
|
}
|
|
54
65
|
|
|
@@ -56,7 +67,7 @@ function extractArchive(src, dest) {
|
|
|
56
67
|
if (process.platform === "win32") {
|
|
57
68
|
execSync(
|
|
58
69
|
`powershell -NoProfile -Command "Expand-Archive -Path '${src}' -DestinationPath '${dest}' -Force"`,
|
|
59
|
-
{ stdio: "ignore" }
|
|
70
|
+
{ stdio: "ignore" },
|
|
60
71
|
);
|
|
61
72
|
return;
|
|
62
73
|
}
|