aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Hartlage <ryanplusplus@gmail.com>2016-04-18 19:39:09 -0400
committerRyan Hartlage <ryanplusplus@gmail.com>2016-04-18 19:41:05 -0400
commit05c1c8b0699d5ac8a85a844332d6b6ae0dff0c89 (patch)
treea3b5048cd82e7880feb51f647a02a38c0f4a9b84
parent09da2f695b3e531e8bc88082e9f06f3875685cab (diff)
downloadluarocks-05c1c8b0699d5ac8a85a844332d6b6ae0dff0c89.tar.gz
luarocks-05c1c8b0699d5ac8a85a844332d6b6ae0dff0c89.tar.bz2
luarocks-05c1c8b0699d5ac8a85a844332d6b6ae0dff0c89.zip
Add support for the --tree argument to the path command
-rw-r--r--src/luarocks/cfg.lua12
-rw-r--r--src/luarocks/path_cmd.lua2
-rw-r--r--test/testing.lua1
-rwxr-xr-xtest/testing.sh1
4 files changed, 12 insertions, 4 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index 0099ec3a..f01fd205 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -666,17 +666,23 @@ function cfg.make_paths_from_tree(tree)
666 return lua_path, lib_path, bin_path 666 return lua_path, lib_path, bin_path
667end 667end
668 668
669function cfg.package_paths() 669function cfg.package_paths(current)
670 local new_path, new_cpath, new_bin = {}, {}, {} 670 local new_path, new_cpath, new_bin = {}, {}, {}
671 for _,tree in ipairs(cfg.rocks_trees) do 671 local function add_tree_to_paths(tree)
672 local lua_path, lib_path, bin_path = cfg.make_paths_from_tree(tree) 672 local lua_path, lib_path, bin_path = cfg.make_paths_from_tree(tree)
673 table.insert(new_path, lua_path.."/?.lua") 673 table.insert(new_path, lua_path.."/?.lua")
674 table.insert(new_path, lua_path.."/?/init.lua") 674 table.insert(new_path, lua_path.."/?/init.lua")
675 table.insert(new_cpath, lib_path.."/?."..cfg.lib_extension) 675 table.insert(new_cpath, lib_path.."/?."..cfg.lib_extension)
676 table.insert(new_bin, bin_path) 676 table.insert(new_bin, bin_path)
677 end 677 end
678 if current then
679 add_tree_to_paths(current)
680 end
681 for _,tree in ipairs(cfg.rocks_trees) do
682 add_tree_to_paths(tree)
683 end
678 if extra_luarocks_module_dir then 684 if extra_luarocks_module_dir then
679 table.insert(new_path, extra_luarocks_module_dir) 685 table.insert(new_path, extra_luarocks_module_dir)
680 end 686 end
681 return table.concat(new_path, ";"), table.concat(new_cpath, ";"), table.concat(new_bin, cfg.export_path_separator) 687 return table.concat(new_path, ";"), table.concat(new_cpath, ";"), table.concat(new_bin, cfg.export_path_separator)
682end 688end
diff --git a/src/luarocks/path_cmd.lua b/src/luarocks/path_cmd.lua
index 2bee4cb5..ecd6d4b1 100644
--- a/src/luarocks/path_cmd.lua
+++ b/src/luarocks/path_cmd.lua
@@ -37,7 +37,7 @@ function path_cmd.run(...)
37 local flags = util.parse_flags(...) 37 local flags = util.parse_flags(...)
38 local deps_mode = deps.get_deps_mode(flags) 38 local deps_mode = deps.get_deps_mode(flags)
39 39
40 local lr_path, lr_cpath, lr_bin = cfg.package_paths() 40 local lr_path, lr_cpath, lr_bin = cfg.package_paths(flags["tree"])
41 local path_sep = cfg.export_path_separator 41 local path_sep = cfg.export_path_separator
42 42
43 if flags["lr-path"] then 43 if flags["lr-path"] then
diff --git a/test/testing.lua b/test/testing.lua
index 6d4b4b05..c37293ee 100644
--- a/test/testing.lua
+++ b/test/testing.lua
@@ -266,6 +266,7 @@ local tests = {
266 test_path_lr_path = function() return run "$luarocks path --lr-path" end, 266 test_path_lr_path = function() return run "$luarocks path --lr-path" end,
267 test_path_lr_cpath = function() return run "$luarocks path --lr-cpath" end, 267 test_path_lr_cpath = function() return run "$luarocks path --lr-cpath" end,
268 test_path_lr_bin = function() return run "$luarocks path --lr-bin" end, 268 test_path_lr_bin = function() return run "$luarocks path --lr-bin" end,
269 test_path_with_tree = function() return run "$luarocks path --tree=lua_modules" end,
269 fail_purge_missing_tree = function() return run '$luarocks purge --tree="$testing_tree"' end, 270 fail_purge_missing_tree = function() return run '$luarocks purge --tree="$testing_tree"' end,
270 test_purge = function() return run '$luarocks purge --tree="$testing_sys_tree"' end, 271 test_purge = function() return run '$luarocks purge --tree="$testing_sys_tree"' end,
271 test_remove = function() 272 test_remove = function()
diff --git a/test/testing.sh b/test/testing.sh
index 95b3243c..305168c8 100755
--- a/test/testing.sh
+++ b/test/testing.sh
@@ -449,6 +449,7 @@ test_path() { $luarocks path --bin; }
449test_path_lr_path() { $luarocks path --lr-path; } 449test_path_lr_path() { $luarocks path --lr-path; }
450test_path_lr_cpath() { $luarocks path --lr-cpath; } 450test_path_lr_cpath() { $luarocks path --lr-cpath; }
451test_path_lr_bin() { $luarocks path --lr-bin; } 451test_path_lr_bin() { $luarocks path --lr-bin; }
452test_path_with_tree() { $luarocks path --tree=lua_modules; }
452 453
453fail_purge_missing_tree() { $luarocks purge --tree="$testing_tree"; } 454fail_purge_missing_tree() { $luarocks purge --tree="$testing_tree"; }
454fail_purge_tree_notstring() { $luarocks purge --tree=1; } 455fail_purge_tree_notstring() { $luarocks purge --tree=1; }