Skip to content

Commit

Permalink
luarocks show: split direct and indirect deps
Browse files Browse the repository at this point in the history
Additionally show constraints for direct deps and
versions used for all deps.
  • Loading branch information
mpeterv committed Mar 22, 2016
1 parent b0d396b commit 0af7e42
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/luarocks/show.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ function show.pick_installed_rock(name, version, tree)
return name, version, repo, repo_url
end

local function installed_rock_label(name, tree)
local installed, version
if cfg.rocks_provided[name] then
installed, version = true, cfg.rocks_provided[name]
else
installed, version = show.pick_installed_rock(name, nil, tree)
end
return installed and "(using "..version..")" or "(missing)"
end

--- Driver function for "show" command.
-- @param name or nil: an existing package name.
-- @param version string or nil: a version may also be passed.
Expand Down Expand Up @@ -145,10 +155,26 @@ function show.run(...)
util.printout("\t"..mod.." ("..path.which(mod, filename, name, version, repo, manifest)..")")
end
end
if next(minfo.dependencies) then
local direct_deps = {}
if #rockspec.dependencies > 0 then
util.printout()
util.printout("Depends on:")
util.printout("\t"..keys_as_string(minfo.dependencies, "\n\t"))
for _, dep in ipairs(rockspec.dependencies) do
direct_deps[dep.name] = true
util.printout("\t"..deps.show_dep(dep).." "..installed_rock_label(dep.name, flags["tree"]))
end
end
local has_indirect_deps
for dep_name in util.sortedpairs(minfo.dependencies) do
if not direct_deps[dep_name] then
if not has_indirect_deps then
util.printout()
util.printout("Indirectly pulling:")
has_indirect_deps = true
end

util.printout("\t"..dep_name.." "..installed_rock_label(dep_name, flags["tree"]))
end
end
util.printout()
end
Expand Down

0 comments on commit 0af7e42

Please sign in to comment.