Skip to content

Commit

Permalink
which: find modules installed in a project tree
Browse files Browse the repository at this point in the history
Fixes #882.
  • Loading branch information
hishamhm committed Aug 11, 2018
1 parent b88ca6d commit ba7e692
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/luarocks/cmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ local cmd = {}

local unpack = unpack or table.unpack

local cfg = require("luarocks.core.cfg")
local loader = require("luarocks.loader")
local util = require("luarocks.util")
local path = require("luarocks.path")
local deps = require("luarocks.deps")
local cfg = require("luarocks.core.cfg")
local dir = require("luarocks.dir")
local fun = require("luarocks.fun")
local fs = require("luarocks.fs")
Expand Down Expand Up @@ -206,6 +207,7 @@ do
elseif flags["project-tree"] then
local tree = flags["project-tree"]
table.insert(cfg.rocks_trees, 1, { name = "project", root = tree } )
loader.load_rocks_trees()
path.use_tree(tree)
elseif flags["local"] then
if not cfg.home_tree then
Expand All @@ -218,6 +220,7 @@ do
local project_dir, rocks_tree = find_project_dir()
if project_dir then
table.insert(cfg.rocks_trees, 1, { name = "project", root = rocks_tree } )
loader.load_rocks_trees()
path.use_tree(rocks_tree)
else
local trees = cfg.rocks_trees
Expand Down
6 changes: 3 additions & 3 deletions src/luarocks/loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ loader.context = {}
-- 'nil' indicates rocks trees were not attempted to be loaded yet.
loader.rocks_trees = nil

local function load_rocks_trees()
function loader.load_rocks_trees()
local any_ok = false
local trees = {}
for _, tree in ipairs(cfg.rocks_trees) do
Expand Down Expand Up @@ -95,7 +95,7 @@ function loader.add_context(name, version)
end
loader.context[name] = version

if not loader.rocks_trees and not load_rocks_trees() then
if not loader.rocks_trees and not loader.load_rocks_trees() then
return nil
end

Expand Down Expand Up @@ -191,7 +191,7 @@ local function select_module(module, filter_file_name)
--assert(type(module) == "string")
--assert(type(filter_module_name) == "function")

if not loader.rocks_trees and not load_rocks_trees() then
if not loader.rocks_trees and not loader.load_rocks_trees() then
return nil
end

Expand Down

0 comments on commit ba7e692

Please sign in to comment.