diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/command_line.lua | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 07f86a7f..40ad06af 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua | |||
| @@ -53,6 +53,17 @@ local function is_ownership_ok(directory) | |||
| 53 | return false | 53 | return false |
| 54 | end | 54 | end |
| 55 | 55 | ||
| 56 | local function find_project_dir() | ||
| 57 | local try = "." | ||
| 58 | for _ = 1, 10 do -- FIXME detect when root dir was hit instead | ||
| 59 | local abs = fs.absolute_name(try) | ||
| 60 | if fs.is_dir(abs .. "/.luarocks") and fs.is_dir(abs .. "/lua_modules") then | ||
| 61 | return abs, abs .. "/lua_modules" | ||
| 62 | end | ||
| 63 | try = try .. "/.." | ||
| 64 | end | ||
| 65 | end | ||
| 66 | |||
| 56 | --- Main command-line processor. | 67 | --- Main command-line processor. |
| 57 | -- Parses input arguments and calls the appropriate driver function | 68 | -- Parses input arguments and calls the appropriate driver function |
| 58 | -- to execute the action requested on the command-line, forwarding | 69 | -- to execute the action requested on the command-line, forwarding |
| @@ -159,8 +170,13 @@ function command_line.run_command(...) | |||
| 159 | end | 170 | end |
| 160 | replace_tree(flags, cfg.home_tree) | 171 | replace_tree(flags, cfg.home_tree) |
| 161 | else | 172 | else |
| 162 | local trees = cfg.rocks_trees | 173 | local project_dir, rocks_tree = find_project_dir() |
| 163 | path.use_tree(trees[#trees]) | 174 | if project_dir then |
| 175 | path.use_tree(rocks_tree) | ||
| 176 | else | ||
| 177 | local trees = cfg.rocks_trees | ||
| 178 | path.use_tree(trees[#trees]) | ||
| 179 | end | ||
| 164 | end | 180 | end |
| 165 | 181 | ||
| 166 | if type(cfg.root_dir) == "string" then | 182 | if type(cfg.root_dir) == "string" then |
