Added a check for if a package is already installed
Installing packages is now fully functional (aside from specific versions)
This commit is contained in:
+17
-12
@@ -131,22 +131,24 @@ end
|
|||||||
local failure = false
|
local failure = false
|
||||||
local dependencyCounter = 0
|
local dependencyCounter = 0
|
||||||
if command == "install" then
|
if command == "install" then
|
||||||
if #packages == 0 then
|
for i = 1, #packages do
|
||||||
print("\27[91mNo packages specified.\n\27[0mExiting.")
|
if fs.exists(("/ag2/pkg/%s.json"):format(packages[i])) then
|
||||||
return
|
print(("\27[93mPackage %s is already installed, skipping"):format(packages[i]))
|
||||||
end
|
table.remove(packages, i)
|
||||||
for i, package in ipairs(packages) do
|
i = i - 1
|
||||||
|
goto SKIP
|
||||||
|
end
|
||||||
local source = parsed.s or parsed.source
|
local source = parsed.s or parsed.source
|
||||||
if not registry[package] and not source then
|
if not registry[packages[i]] and not source then
|
||||||
print("\27[91mCould not find package in registry and no source provided: " .. package)
|
print("\27[91mCould not find package in registry and no source provided: " .. packages[i])
|
||||||
failure = true
|
failure = true
|
||||||
goto SKIP
|
goto SKIP
|
||||||
else
|
else
|
||||||
source = registry[package]
|
source = registry[packages[i]]
|
||||||
end
|
end
|
||||||
local success, data = getFile(fs.concat(source, "/ag2.json"))
|
local success, data = getFile(fs.concat(source, "/ag2.json"))
|
||||||
if not success then
|
if not success then
|
||||||
print(("\27[91mFailed to get package config (ag2.json) of package '%s': " .. data):format(package))
|
print(("\27[91mFailed to get package config (ag2.json) of package '%s': " .. data):format(packages[i]))
|
||||||
failure = true
|
failure = true
|
||||||
goto SKIP
|
goto SKIP
|
||||||
end
|
end
|
||||||
@@ -154,11 +156,11 @@ if command == "install" then
|
|||||||
return json.decode(data)
|
return json.decode(data)
|
||||||
end)
|
end)
|
||||||
if not success then
|
if not success then
|
||||||
print(("\27[91mFailed to parse package config (ag2.json) of package '%s': " .. packageConfig):format(package))
|
print(("\27[91mFailed to parse package config (ag2.json) of package '%s': " .. packageConfig):format(packages[i]))
|
||||||
failure = true
|
failure = true
|
||||||
goto SKIP
|
goto SKIP
|
||||||
end
|
end
|
||||||
if not packageConfig[package] then
|
if not packageConfig[packages[i]] then
|
||||||
print(("\27[91mRepository package config (ag2.json) does not contain package '%s'."):format(package))
|
print(("\27[91mRepository package config (ag2.json) does not contain package '%s'."):format(package))
|
||||||
failure = true
|
failure = true
|
||||||
goto SKIP
|
goto SKIP
|
||||||
@@ -170,9 +172,12 @@ if command == "install" then
|
|||||||
dependencyCounter = dependencyCounter + 1
|
dependencyCounter = dependencyCounter + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- TODO: Add check for if package exists
|
|
||||||
::SKIP::
|
::SKIP::
|
||||||
end
|
end
|
||||||
|
if #packages == 0 then
|
||||||
|
print("\27[91mNo packages to install.\n\27[0mExiting.")
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
-- TODO: Add checks for the other commands
|
-- TODO: Add checks for the other commands
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user