Skip to content

Commit a9f03e1

Browse files
Copilotbytemain
andcommitted
Address code review feedback: improve readability
Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com>
1 parent 9ecd403 commit a9f03e1

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

hooks/available.lua

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ local distribution_version_parser = require("distribution_version")
77
function PLUGIN:Available(ctx)
88
local query = ctx.args[1] or "open"
99
local jdks = {}
10+
local distribution = nil
1011

1112
if query == "all" then
12-
for _, distribution in ipairs(distribution_version_parser.distributions) do
13-
local tempJdks = foojay.fetchtJdkList(distribution.name, "")
13+
for _, dist in ipairs(distribution_version_parser.distributions) do
14+
local tempJdks = foojay.fetchtJdkList(dist.name, "")
1415
for _, jdk in ipairs(tempJdks) do
15-
jdk.short = distribution.short_name
16+
jdk.short = dist.short_name
1617
table.insert(jdks, jdk)
1718
end
1819
end
1920
else
20-
local distribution = distribution_version_parser.parse_distribution(query)
21+
distribution = distribution_version_parser.parse_distribution(query)
2122
if not distribution then
2223
error("Unsupported distribution: " .. query)
2324
end
@@ -41,10 +42,6 @@ function PLUGIN:Available(ctx)
4142
elseif query == "open" then
4243
v = v .. fx_suffix
4344
else
44-
local distribution = distribution_version_parser.parse_distribution(query)
45-
if not distribution then
46-
error("Unsupported distribution: " .. query)
47-
end
4845
v = v .. fx_suffix .. "-" .. distribution.short_name
4946
end
5047

hooks/pre_install.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ function PLUGIN:PreInstall(ctx)
4545
if jdk.javafx_bundled == true then
4646
fx_suffix = "-fx"
4747
end
48-
local finalV = distribution_version.distribution.short_name == "open" and jdk.java_version .. fx_suffix or jdk.java_version .. fx_suffix .. "-" .. distribution_version.distribution.short_name
48+
49+
local finalV
50+
if distribution_version.distribution.short_name == "open" then
51+
finalV = jdk.java_version .. fx_suffix
52+
else
53+
finalV = jdk.java_version .. fx_suffix .. "-" .. distribution_version.distribution.short_name
54+
end
4955
return {
5056
-- [info.checksum_type] = checksum,
5157
url = info.direct_download_uri,

0 commit comments

Comments
 (0)