From 9a67a7c047b6d743c8f9e534720b49c2fa25962b Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Thu, 24 May 2018 14:04:37 -0300 Subject: put project dir up front for module search paths, but enable it as default --- src/luarocks/command_line.lua | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 27965212..a8977c24 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua @@ -143,15 +143,10 @@ function command_line.run_command(...) end if flags["project-tree"] then - table.insert(cfg.rocks_trees, 1, { name = "project", root = flags["project-tree"] } ) - else - local project_dir, rocks_tree = find_project_dir() - if project_dir then - table.insert(cfg.rocks_trees, 1, { name = "project", root = rocks_tree } ) - end - end - - if flags["tree"] then + local tree = flags["project-tree"] + table.insert(cfg.rocks_trees, 1, { name = "project", root = tree } ) + path.use_tree(tree) + elseif flags["tree"] then local named = false for _, tree in ipairs(cfg.rocks_trees) do if type(tree) == "table" and flags["tree"] == tree.name then @@ -175,8 +170,14 @@ function command_line.run_command(...) end replace_tree(flags, cfg.home_tree) else - local trees = cfg.rocks_trees - path.use_tree(trees[#trees]) + local project_dir, rocks_tree = find_project_dir() + if project_dir then + table.insert(cfg.rocks_trees, 1, { name = "project", root = rocks_tree } ) + path.use_tree(rocks_tree) + else + local trees = cfg.rocks_trees + path.use_tree(trees[#trees]) + end end if type(cfg.root_dir) == "string" then -- cgit v1.2.3-55-g6feb