Skip to content

Commit

Permalink
Exit gracefully if there is no error
Browse files Browse the repository at this point in the history
  • Loading branch information
yanecc committed May 26, 2024
1 parent 890a494 commit 5fd0aae
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
1 change: 0 additions & 1 deletion .gitignore

This file was deleted.

Empty file removed .tool-versions
Empty file.
12 changes: 8 additions & 4 deletions lib/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ function getDownloadInfo(version)
local headers
local dataVersion = util.dataVersion
if RUNTIME.archType ~= "amd64" and RUNTIME.osType ~= "darwin" then
error("Crystal does not provide " .. RUNTIME.osType .. "-" .. RUNTIME.archType .. " release")
print("Crystal does not provide " .. RUNTIME.osType .. "-" .. RUNTIME.archType .. " release")
os.exit(1)
end
if version == "latest" then
version = getLatestVersion()
Expand Down Expand Up @@ -84,10 +85,12 @@ function generateNightlyURL(osType, archType)
if isGithubToken(util.githubToken) then
file, headers = fetchWinNightly()
else
error("Please provide a valid GitHub Token to download Windows nightly builds")
print("Please provide a valid GitHub Token to download Windows nightly builds")
os.exit(1)
end
else
error("Crystal doesn't provide nightly builds for " .. osType .. "-" .. archType)
print("Crystal doesn't provide nightly builds for " .. osType .. "-" .. archType)
os.exit(1)
end

return file, headers
Expand Down Expand Up @@ -138,7 +141,8 @@ end
function fetchAvailable(noCache)
local result = {}
if RUNTIME.archType ~= "amd64" and RUNTIME.osType ~= "darwin" then
error("Crystal does not provide " .. RUNTIME.osType .. "-" .. RUNTIME.archType .. " release")
print("Crystal does not provide " .. RUNTIME.osType .. "-" .. RUNTIME.archType .. " release")
os.exit(1)
end
if noCache then
clearCache()
Expand Down
8 changes: 5 additions & 3 deletions lib/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ function generateURL(version, osType, archType)
elseif archType == "amd64" then
file = baseURL .. "1-darwin-x86_64.tar.gz"
else
error("Crystal does not provide darwin-" .. archType .. " v" .. version .. " release")
print("Crystal does not provide darwin-" .. archType .. " v" .. version .. " release")
os.exit(1)
end
elseif osType == "linux" and archType == "amd64" then
file = baseURL .. "1-linux-x86_64.tar.gz"
elseif osType == "windows" and archType == "amd64" then
file = baseURL .. "windows-x86_64-msvc-unsupported.zip"
else
error("Crystal does not provide " .. osType .. "-" .. archType .. " release")
print("Crystal does not provide " .. osType .. "-" .. archType .. " release")
os.exit(1)
end
file = file:format(version, version)

Expand All @@ -55,7 +57,7 @@ function isGithubToken(token)
-- Personal Access Token (Classic)
if token:match("^ghp_" .. character:rep(36) .. "$") then
return true
-- Personal Access Token (Fine-Grained)
-- Personal Access Token (Fine-Grained)
elseif token:match("^github_pat_" .. character:rep(22) .. "_" .. character:rep(59) .. "$") then
return true
end
Expand Down
2 changes: 1 addition & 1 deletion metadata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PLUGIN = {}
--- Plugin name
PLUGIN.name = "crystal"
--- Plugin version
PLUGIN.version = "0.5.1"
PLUGIN.version = "0.5.3"
--- Plugin homepage
PLUGIN.homepage = "https://github.com/yanecc/vfox-crystal"
--- Plugin license, please choose a correct license according to your needs.
Expand Down

0 comments on commit 5fd0aae

Please sign in to comment.