diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/cmd.lua | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index b2f036bf..284b1602 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
@@ -157,15 +157,18 @@ local function get_lua_version(flags) | |||
157 | return flags["lua-version"] | 157 | return flags["lua-version"] |
158 | end | 158 | end |
159 | local dirs = {} | 159 | local dirs = {} |
160 | if cfg.home_tree then | 160 | local next_i = 1 |
161 | dirs[1] = dir.path(cfg.home_tree, ".luarocks") | ||
162 | end | ||
163 | table.insert(dirs, cfg.sysconfdir) | ||
164 | if flags["project-tree"] then | 161 | if flags["project-tree"] then |
165 | table.insert(dirs, 1, dir.path(flags["project-tree"], "..", ".luarocks")) | 162 | dirs[next_i] = dir.path(flags["project-tree"], "..", ".luarocks") |
163 | next_i = next_i + 1 | ||
164 | end | ||
165 | if cfg.home_tree then | ||
166 | dirs[next_i] = dir.path(cfg.home_tree, ".luarocks") | ||
167 | next_i = next_i + 1 | ||
166 | end | 168 | end |
167 | for _, d in ipairs(dirs) do | 169 | dirs[next_i] = cfg.sysconfdir |
168 | local f = dir.path(d, "default-lua-version.lua") | 170 | for i=1, next_i do |
171 | local f = dir.path(dirs[i], "default-lua-version.lua") | ||
169 | local mod, err = loadfile(f, "t") | 172 | local mod, err = loadfile(f, "t") |
170 | if mod then | 173 | if mod then |
171 | local pok, ver = pcall(mod) | 174 | local pok, ver = pcall(mod) |