replace pairs with ipairs where necessary
This commit is contained in:
@ -125,7 +125,7 @@ function M.synctree(tree, cb)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, package in pairs(tree) do
|
for _, package in ipairs(tree) do
|
||||||
local co = coroutine.create(function()
|
local co = coroutine.create(function()
|
||||||
-- if the package provided prefers a local source then use the local
|
-- if the package provided prefers a local source then use the local
|
||||||
-- source instead of the git repository
|
-- source instead of the git repository
|
||||||
@ -170,7 +170,7 @@ return function(opts)
|
|||||||
M.registertree(opts)
|
M.registertree(opts)
|
||||||
|
|
||||||
-- sort package dependencies
|
-- sort package dependencies
|
||||||
for _, package in pairs(packager.get_packages()) do
|
for _, package in ipairs(packager.get_packages()) do
|
||||||
table.sort(package.requirements, comp)
|
table.sort(package.requirements, comp)
|
||||||
table.sort(package.dependents, comp)
|
table.sort(package.dependents, comp)
|
||||||
end
|
end
|
||||||
@ -198,7 +198,7 @@ return function(opts)
|
|||||||
|
|
||||||
-- get all package that need syncing
|
-- get all package that need syncing
|
||||||
local targets = {}
|
local targets = {}
|
||||||
for _, package in pairs(packager.get_packages()) do
|
for _, package in ipairs(packager.get_packages()) do
|
||||||
if shouldsync(package) then
|
if shouldsync(package) then
|
||||||
table.insert(targets, package)
|
table.insert(targets, package)
|
||||||
end
|
end
|
||||||
|
@ -40,7 +40,7 @@ function fs:clean(package)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- keep packages that still exist
|
-- keep packages that still exist
|
||||||
for _, pkg in pairs(package.get_packages()) do
|
for _, pkg in ipairs(package.get_packages()) do
|
||||||
queue[pkg.name] = nil
|
queue[pkg.name] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ function package:new(spec, overrides)
|
|||||||
if spec.reqs then
|
if spec.reqs then
|
||||||
---it is the correct type as asserted in check_spec()
|
---it is the correct type as asserted in check_spec()
|
||||||
---@diagnostic disable-next-line: param-type-mismatch
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
for _, req in pairs(spec.reqs) do
|
for _, req in ipairs(spec.reqs) do
|
||||||
local pkg = package:new(req)
|
local pkg = package:new(req)
|
||||||
if type(pkg) == "table" then
|
if type(pkg) == "table" then
|
||||||
o:link_dependency(pkg, o)
|
o:link_dependency(pkg, o)
|
||||||
@ -327,7 +327,7 @@ function package:new(spec, overrides)
|
|||||||
if spec.deps then
|
if spec.deps then
|
||||||
---it is the correct type as asserted in check_spec()
|
---it is the correct type as asserted in check_spec()
|
||||||
---@diagnostic disable-next-line: param-type-mismatch
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
for _, dep in pairs(spec.deps) do
|
for _, dep in ipairs(spec.deps) do
|
||||||
local pkg = package:new(dep)
|
local pkg = package:new(dep)
|
||||||
if not pkg then
|
if not pkg then
|
||||||
return false
|
return false
|
||||||
@ -425,7 +425,7 @@ function package:ensureadded(force)
|
|||||||
---@param pkg package
|
---@param pkg package
|
||||||
local function loadpkg(pkg)
|
local function loadpkg(pkg)
|
||||||
-- make sure to load the dependencies first
|
-- make sure to load the dependencies first
|
||||||
for _, p in pairs(pkg.requirements) do
|
for _, p in ipairs(pkg.requirements) do
|
||||||
if not p.loaded then
|
if not p.loaded then
|
||||||
p:ensureadded(true)
|
p:ensureadded(true)
|
||||||
end
|
end
|
||||||
@ -506,7 +506,7 @@ function package:loadtree(force)
|
|||||||
|
|
||||||
-- if the package isn't lazy check that it's requirements are loaded
|
-- if the package isn't lazy check that it's requirements are loaded
|
||||||
if not self.lazy then
|
if not self.lazy then
|
||||||
for _, requirement in pairs(self.requirements) do
|
for _, requirement in ipairs(self.requirements) do
|
||||||
if not requirement.loaded and not requirement.lazy then
|
if not requirement.loaded and not requirement.lazy then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -526,7 +526,7 @@ function package:loadtree(force)
|
|||||||
self.subtree_loaded = true
|
self.subtree_loaded = true
|
||||||
|
|
||||||
-- make sure the dependants are loaded
|
-- make sure the dependants are loaded
|
||||||
for _, dependant in pairs(self.dependents) do
|
for _, dependant in ipairs(self.dependents) do
|
||||||
self.subtree_loaded = dependant:loadtree(force) and self.subtree_loaded
|
self.subtree_loaded = dependant:loadtree(force) and self.subtree_loaded
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -536,12 +536,12 @@ end
|
|||||||
--- unconfigure a packages tree
|
--- unconfigure a packages tree
|
||||||
function package:unconfiguretree()
|
function package:unconfiguretree()
|
||||||
-- unconfigure requirements
|
-- unconfigure requirements
|
||||||
for _, requirement in pairs(self.requirements) do
|
for _, requirement in ipairs(self.requirements) do
|
||||||
requirement.subtree_loaded = false
|
requirement.subtree_loaded = false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- unconfigure dependents
|
-- unconfigure dependents
|
||||||
for _, dependant in pairs(self.dependents) do
|
for _, dependant in ipairs(self.dependents) do
|
||||||
dependant.loaded = false
|
dependant.loaded = false
|
||||||
dependant.added = false
|
dependant.added = false
|
||||||
dependant.configured = false
|
dependant.configured = false
|
||||||
@ -602,7 +602,7 @@ function package.findcycle(pkgs)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- actually check the cycle
|
-- actually check the cycle
|
||||||
for _, pkg in pairs(pkgs) do
|
for _, pkg in ipairs(pkgs) do
|
||||||
if not indexes[package.id] then
|
if not indexes[package.id] then
|
||||||
local cycle = connect(pkg)
|
local cycle = connect(pkg)
|
||||||
if cycle then
|
if cycle then
|
||||||
|
Reference in New Issue
Block a user