From 20639f221c605cc1788262af7e8a489adad2ef64 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Sat, 6 Apr 2013 16:12:48 -0300 Subject: Fix crash in the 'show' command when using a table as entry in rocks_trees config file. --- src/luarocks/path.lua | 10 +++++++++- src/luarocks/show.lua | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index 64a203ef..2ce0e078 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua @@ -37,11 +37,19 @@ end function root_dir(rocks_dir) assert(type(rocks_dir) == "string") - local suffix = dir.path("lib", "luarocks") return rocks_dir:match("(.*)" .. suffix .. ".*$") end +function rocks_tree_to_string(tree) + if type(tree) == "string" then + return tree + else + assert(type(tree) == "table") + return tree.root + end +end + function deploy_bin_dir(tree) if type(tree) == "string" then return dir.path(tree, "bin") diff --git a/src/luarocks/show.lua b/src/luarocks/show.lua index 7849934d..a6a53d9a 100644 --- a/src/luarocks/show.lua +++ b/src/luarocks/show.lua @@ -115,7 +115,7 @@ function run(...) if not manifest then return nil,err end local minfo = manifest.repository[name][version][1] - if flags["rock-tree"] then util.printout(repo) + if flags["rock-tree"] then util.printout(path.rocks_tree_to_string(repo)) elseif flags["rock-dir"] then util.printout(directory) elseif flags["home"] then util.printout(descript.homepage) elseif flags["modules"] then util.printout(keys_as_string(minfo.modules)) @@ -136,7 +136,7 @@ function run(...) if descript.homepage then util.printout("Homepage: ", descript.homepage) end - util.printout("Installed in: ", repo) + util.printout("Installed in: ", path.rocks_tree_to_string(repo)) if next(minfo.modules) then util.printout() util.printout("Modules:") -- cgit v1.2.3-55-g6feb