Skip to content

Commit c441c0f

Browse files
authored
Update pre_install.lua - gh
1 parent db3d74c commit c441c0f

File tree

1 file changed

+6
-26
lines changed

1 file changed

+6
-26
lines changed

hooks/pre_install.lua

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,11 @@
11
-- hooks/pre_install.lua
22
function PLUGIN:PreInstall(ctx)
33
local version = ctx.version
4-
local http = require("http")
4+
local helper = require("helper")
55

6-
-- Normalize architecture
7-
local arch = RUNTIME.archType:lower()
8-
local arch_token
9-
if arch == "amd64" or arch == "x86_64" then
10-
arch_token = "amd64"
11-
elseif arch == "arm64" or arch == "aarch64" then
12-
arch_token = "aarch64"
13-
else
14-
error("Unsupported architecture: " .. RUNTIME.archType)
15-
end
16-
17-
-- Normalize OS
18-
local os_l = RUNTIME.osType:lower()
19-
local os_token
20-
if os_l:find("windows") then
21-
os_token = "windows"
22-
elseif os_l:find("darwin") then
23-
os_token = "macos"
24-
elseif os_l:find("linux") then
25-
os_token = "linux"
26-
else
27-
error("Unsupported OS: " .. RUNTIME.osType)
28-
end
6+
-- Get normalized OS and architecture
7+
local os_token = helper.get_os()
8+
local arch_token = helper.get_arch()
299

3010
-- Construct filename (dynamic builds)
3111
local filename = string.format("eca-native-%s-%s.zip", os_token, arch_token)
@@ -34,8 +14,8 @@ function PLUGIN:PreInstall(ctx)
3414
-- Fetch checksum
3515
local sha256
3616
do
37-
local resp, err = http.get({url = url .. ".sha256"})
38-
if not err and resp.status_code == 200 then
17+
local resp, err = helper.github_request(url .. ".sha256")
18+
if not err and resp then
3919
sha256 = resp.body:match("^(%w+)")
4020
end
4121
end

0 commit comments

Comments
 (0)