From f893acf2409bb4ec8a4669a9e4380a98737c6b40 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Fri, 10 Aug 2018 22:35:57 -0300 Subject: which: find modules installed in a project tree Fixes #882. --- src/luarocks/cmd.lua | 5 ++++- src/luarocks/loader.lua | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 2c5a3655..f85821a5 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua @@ -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") @@ -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 @@ -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 diff --git a/src/luarocks/loader.lua b/src/luarocks/loader.lua index a8a9cfdf..4df55a04 100644 --- a/src/luarocks/loader.lua +++ b/src/luarocks/loader.lua @@ -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 @@ -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 @@ -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 -- cgit v1.2.3-55-g6feb