diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2018-08-10 22:35:57 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-08-10 22:49:47 -0300 |
| commit | f893acf2409bb4ec8a4669a9e4380a98737c6b40 (patch) | |
| tree | 1cd26b5d8f4bb823b15a4744e4f625a01c2c7e82 | |
| parent | b5926be6dd3438c7f98afe7c9ffb28f52fb6a573 (diff) | |
| download | luarocks-f893acf2409bb4ec8a4669a9e4380a98737c6b40.tar.gz luarocks-f893acf2409bb4ec8a4669a9e4380a98737c6b40.tar.bz2 luarocks-f893acf2409bb4ec8a4669a9e4380a98737c6b40.zip | |
which: find modules installed in a project tree
Fixes #882.
| -rw-r--r-- | src/luarocks/cmd.lua | 5 | ||||
| -rw-r--r-- | 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 = {} | |||
| 4 | 4 | ||
| 5 | local unpack = unpack or table.unpack | 5 | local unpack = unpack or table.unpack |
| 6 | 6 | ||
| 7 | local cfg = require("luarocks.core.cfg") | 7 | local loader = require("luarocks.loader") |
| 8 | local util = require("luarocks.util") | 8 | local util = require("luarocks.util") |
| 9 | local path = require("luarocks.path") | 9 | local path = require("luarocks.path") |
| 10 | local deps = require("luarocks.deps") | 10 | local deps = require("luarocks.deps") |
| 11 | local cfg = require("luarocks.core.cfg") | ||
| 11 | local dir = require("luarocks.dir") | 12 | local dir = require("luarocks.dir") |
| 12 | local fun = require("luarocks.fun") | 13 | local fun = require("luarocks.fun") |
| 13 | local fs = require("luarocks.fs") | 14 | local fs = require("luarocks.fs") |
| @@ -206,6 +207,7 @@ do | |||
| 206 | elseif flags["project-tree"] then | 207 | elseif flags["project-tree"] then |
| 207 | local tree = flags["project-tree"] | 208 | local tree = flags["project-tree"] |
| 208 | table.insert(cfg.rocks_trees, 1, { name = "project", root = tree } ) | 209 | table.insert(cfg.rocks_trees, 1, { name = "project", root = tree } ) |
| 210 | loader.load_rocks_trees() | ||
| 209 | path.use_tree(tree) | 211 | path.use_tree(tree) |
| 210 | elseif flags["local"] then | 212 | elseif flags["local"] then |
| 211 | if not cfg.home_tree then | 213 | if not cfg.home_tree then |
| @@ -218,6 +220,7 @@ do | |||
| 218 | local project_dir, rocks_tree = find_project_dir() | 220 | local project_dir, rocks_tree = find_project_dir() |
| 219 | if project_dir then | 221 | if project_dir then |
| 220 | table.insert(cfg.rocks_trees, 1, { name = "project", root = rocks_tree } ) | 222 | table.insert(cfg.rocks_trees, 1, { name = "project", root = rocks_tree } ) |
| 223 | loader.load_rocks_trees() | ||
| 221 | path.use_tree(rocks_tree) | 224 | path.use_tree(rocks_tree) |
| 222 | else | 225 | else |
| 223 | local trees = cfg.rocks_trees | 226 | 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 = {} | |||
| 57 | -- 'nil' indicates rocks trees were not attempted to be loaded yet. | 57 | -- 'nil' indicates rocks trees were not attempted to be loaded yet. |
| 58 | loader.rocks_trees = nil | 58 | loader.rocks_trees = nil |
| 59 | 59 | ||
| 60 | local function load_rocks_trees() | 60 | function loader.load_rocks_trees() |
| 61 | local any_ok = false | 61 | local any_ok = false |
| 62 | local trees = {} | 62 | local trees = {} |
| 63 | for _, tree in ipairs(cfg.rocks_trees) do | 63 | for _, tree in ipairs(cfg.rocks_trees) do |
| @@ -95,7 +95,7 @@ function loader.add_context(name, version) | |||
| 95 | end | 95 | end |
| 96 | loader.context[name] = version | 96 | loader.context[name] = version |
| 97 | 97 | ||
| 98 | if not loader.rocks_trees and not load_rocks_trees() then | 98 | if not loader.rocks_trees and not loader.load_rocks_trees() then |
| 99 | return nil | 99 | return nil |
| 100 | end | 100 | end |
| 101 | 101 | ||
| @@ -191,7 +191,7 @@ local function select_module(module, filter_file_name) | |||
| 191 | --assert(type(module) == "string") | 191 | --assert(type(module) == "string") |
| 192 | --assert(type(filter_module_name) == "function") | 192 | --assert(type(filter_module_name) == "function") |
| 193 | 193 | ||
| 194 | if not loader.rocks_trees and not load_rocks_trees() then | 194 | if not loader.rocks_trees and not loader.load_rocks_trees() then |
| 195 | return nil | 195 | return nil |
| 196 | end | 196 | end |
| 197 | 197 | ||
