diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2018-05-23 11:49:20 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-05-31 11:16:09 -0300 |
commit | c098b60152f9a31f94a27710ffcc1e3842dbb150 (patch) | |
tree | 797ecf978974298d43310834bbea5685cf47ae5a | |
parent | d9fc60e8c924b01be49d5d275effa9d89b48dbd3 (diff) | |
download | luarocks-c098b60152f9a31f94a27710ffcc1e3842dbb150.tar.gz luarocks-c098b60152f9a31f94a27710ffcc1e3842dbb150.tar.bz2 luarocks-c098b60152f9a31f94a27710ffcc1e3842dbb150.zip |
find .luarocks directory and use its location as project root
-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 |