diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2019-03-14 16:41:06 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2019-03-14 21:20:57 -0300 |
| commit | 63c5635f17b8a3d240283166462d9a02935e6750 (patch) | |
| tree | 31908cdec1d5c5c3445eccef0a8fddfbb038f3a7 | |
| parent | f724ec6aae14fba9ab9cfa1087ad0db246f66f5e (diff) | |
| download | luarocks-63c5635f17b8a3d240283166462d9a02935e6750.tar.gz luarocks-63c5635f17b8a3d240283166462d9a02935e6750.tar.bz2 luarocks-63c5635f17b8a3d240283166462d9a02935e6750.zip | |
cmd: if ./.luarocks/config-5.x.lua exists, assume Lua version 5.x by default
| -rw-r--r-- | src/luarocks/cmd.lua | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index ea906726..d7201084 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
| @@ -265,6 +265,19 @@ local function process_server_flags(flags) | |||
| 265 | return true | 265 | return true |
| 266 | end | 266 | end |
| 267 | 267 | ||
| 268 | local function find_lua_version_at(dirname) | ||
| 269 | local lua_version | ||
| 270 | for v in util.lua_versions("descending") do | ||
| 271 | if exists(dir.path(dirname, ".luarocks", "config-"..v..".lua")) then | ||
| 272 | lua_version = v | ||
| 273 | break | ||
| 274 | end | ||
| 275 | end | ||
| 276 | return { | ||
| 277 | lua_version = lua_version | ||
| 278 | } | ||
| 279 | end | ||
| 280 | |||
| 268 | --- Main command-line processor. | 281 | --- Main command-line processor. |
| 269 | -- Parses input arguments and calls the appropriate driver function | 282 | -- Parses input arguments and calls the appropriate driver function |
| 270 | -- to execute the action requested on the command-line, forwarding | 283 | -- to execute the action requested on the command-line, forwarding |
| @@ -395,16 +408,9 @@ function cmd.run_command(description, commands, external_namespace, ...) | |||
| 395 | die("Could not find a Lua interpreter for version " .. flags["lua-version"] .. " in your PATH") | 408 | die("Could not find a Lua interpreter for version " .. flags["lua-version"] .. " in your PATH") |
| 396 | end | 409 | end |
| 397 | elseif project_dir then | 410 | elseif project_dir then |
| 398 | local lua_version | 411 | lua_data = find_lua_version_at(project_dir) |
| 399 | for v in util.lua_versions("descending") do | 412 | else |
| 400 | if exists(dir.path(project_dir, ".luarocks", "config-"..v..".lua")) then | 413 | lua_data = find_lua_version_at(".") |
| 401 | lua_version = v | ||
| 402 | break | ||
| 403 | end | ||
| 404 | end | ||
| 405 | lua_data = { | ||
| 406 | lua_version = lua_version | ||
| 407 | } | ||
| 408 | end | 414 | end |
| 409 | 415 | ||
| 410 | -- FIXME A quick hack for the experimental Windows build | 416 | -- FIXME A quick hack for the experimental Windows build |
