@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.
Files changed (2) hide show
  1. package/install.js +29 -18
  2. 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
- // This gets replaced at publish time with the actual Tigris URL base.
20
- // Override via FAST_DOWNLOAD_URL env var for custom hosting.
21
- const DOWNLOAD_BASE = process.env.FAST_DOWNLOAD_URL || "https://t3.storage.dev/sachinthapa-fast/fast";
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.get(url, (res) => {
39
- if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
40
- download(res.headers.location, dest).then(resolve).catch(reject);
41
- return;
42
- }
43
- if (res.statusCode !== 200) {
44
- reject(new Error(`Download failed: HTTP ${res.statusCode} for ${url}`));
45
- return;
46
- }
47
- const file = createWriteStream(dest);
48
- res.pipe(file);
49
- file.on("finish", () => file.close(resolve));
50
- file.on("error", reject);
51
- }).on("error", reject);
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sachinthapa572/fast",
3
- "version": "0.1.4-rc",
3
+ "version": "0.1.5-rc",
4
4
  "description": "Test your internet speed from the command-line",
5
5
  "bin": {
6
6
  "fast": "cli.js"