Browse Source

Cleanup for the rest of SPM

* Install method needs to be cleaned up significantly, far too much mutation in that method
environments/production/deployments/15
Drew Short 7 years ago
parent
commit
752b779085
  1. 20
      src/spm/spm.lua

20
src/spm/spm.lua

@ -493,8 +493,8 @@ local function uninstallPackage(requestedPackage)
end end
term.write("Removing package files...") term.write("Removing package files...")
for i, j in pairs(locallyInstalledFiles[requestedPackage]) do
fs.remove(j)
for installedFilePath, fileLocalInstallPath in pairs(locallyInstalledFiles[requestedPackage]) do
fs.remove(fileLocalInstallPath)
end end
term.write("Done\nRemoving references...") term.write("Done\nRemoving references...")
@ -504,19 +504,19 @@ local function uninstallPackage(requestedPackage)
print("Successfully uninstalled package " .. requestedPackage) print("Successfully uninstalled package " .. requestedPackage)
end end
local function updatePackage(pack)
if pack == "all" then
local function updatePackage(requestedPackage)
if requestedPackage == "all" then
print("Updating everything...") print("Updating everything...")
local tFiles = readFromLocalInstallFile()
if not tFiles then
local locallyInstalledPackages = readFromLocalInstallFile()
if not locallyInstalledPackages then
io.stderr:write("Error while trying to read package names") io.stderr:write("Error while trying to read package names")
return return
elseif tFiles[1] == -1 then
table.remove(tFiles, 1)
elseif locallyInstalledPackages[1] == -1 then
table.remove(locallyInstalledPackages, 1)
end end
local done = false local done = false
for i in pairs(tFiles) do
installPackage(i, nil, true)
for localPackage in pairs(locallyInstalledPackages) do
installPackage(localPackage, nil, true)
done = true done = true
end end
if not done then if not done then

Loading…
Cancel
Save