diff options
Diffstat (limited to 'src/luarocks/path.lua')
-rw-r--r-- | src/luarocks/path.lua | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index bbd928a0..17d9d52b 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
@@ -7,6 +7,7 @@ module("luarocks.path", package.seeall) | |||
7 | local dir = require("luarocks.dir") | 7 | local dir = require("luarocks.dir") |
8 | local cfg = require("luarocks.cfg") | 8 | local cfg = require("luarocks.cfg") |
9 | local util = require("luarocks.util") | 9 | local util = require("luarocks.util") |
10 | local deps = require("luarocks.deps") | ||
10 | 11 | ||
11 | help_summary = "Return the currently configured package path." | 12 | help_summary = "Return the currently configured package path." |
12 | help_arguments = "" | 13 | help_arguments = "" |
@@ -305,6 +306,27 @@ function use_tree(tree) | |||
305 | cfg.deploy_lib_dir = deploy_lib_dir(tree) | 306 | cfg.deploy_lib_dir = deploy_lib_dir(tree) |
306 | end | 307 | end |
307 | 308 | ||
309 | function map_trees(use_trees, fn, ...) | ||
310 | local result = {} | ||
311 | if use_trees == "one" then | ||
312 | table.insert(result, fn(cfg.root_dir, ...)) | ||
313 | elseif use_trees == "all" or use_trees == "order" then | ||
314 | local use = false | ||
315 | if use_trees == "all" then | ||
316 | use = true | ||
317 | end | ||
318 | for _, tree in ipairs(cfg.rocks_trees) do | ||
319 | if dir.normalize(tree) == dir.normalize(cfg.root_dir) then | ||
320 | use = true | ||
321 | end | ||
322 | if use then | ||
323 | table.insert(result, fn(tree, ...)) | ||
324 | end | ||
325 | end | ||
326 | end | ||
327 | return result | ||
328 | end | ||
329 | |||
308 | --- Return the pathname of the file that would be loaded for a module, indexed. | 330 | --- Return the pathname of the file that would be loaded for a module, indexed. |
309 | -- @param module_name string: module name (eg. "socket.core") | 331 | -- @param module_name string: module name (eg. "socket.core") |
310 | -- @param name string: name of the package (eg. "luasocket") | 332 | -- @param name string: name of the package (eg. "luasocket") |
@@ -352,10 +374,14 @@ end | |||
352 | -- @return boolean This function always succeeds. | 374 | -- @return boolean This function always succeeds. |
353 | function run(...) | 375 | function run(...) |
354 | local flags = util.parse_flags(...) | 376 | local flags = util.parse_flags(...) |
377 | local deps_mode = deps.flags_to_deps_mode(flags) | ||
378 | |||
355 | util.printout(cfg.export_lua_path:format(util.remove_path_dupes(package.path, ';'))) | 379 | util.printout(cfg.export_lua_path:format(util.remove_path_dupes(package.path, ';'))) |
356 | util.printout(cfg.export_lua_cpath:format(util.remove_path_dupes(package.cpath, ';'))) | 380 | util.printout(cfg.export_lua_cpath:format(util.remove_path_dupes(package.cpath, ';'))) |
357 | if flags["bin"] then | 381 | if flags["bin"] then |
358 | util.printout(cfg.export_path:format(util.remove_path_dupes(os.getenv("PATH"), cfg.export_path_separator), cfg.deploy_bin_dir)) | 382 | local bin_dirs = map_trees(deps_mode, deploy_bin_dir) |
383 | table.insert(bin_dirs, 1, os.getenv("PATH")) | ||
384 | util.printout(cfg.export_path:format(util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator))) | ||
359 | end | 385 | end |
360 | return true | 386 | return true |
361 | end | 387 | end |