diff options
Diffstat (limited to 'src/luarocks/command_line.lua')
| -rw-r--r-- | src/luarocks/command_line.lua | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 972302ee..963916bd 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua | |||
| @@ -5,6 +5,7 @@ module("luarocks.command_line", package.seeall) | |||
| 5 | local util = require("luarocks.util") | 5 | local util = require("luarocks.util") |
| 6 | local cfg = require("luarocks.cfg") | 6 | local cfg = require("luarocks.cfg") |
| 7 | local fs = require("luarocks.fs") | 7 | local fs = require("luarocks.fs") |
| 8 | local path = require("luarocks.path") | ||
| 8 | 9 | ||
| 9 | --- Display an error message and exit. | 10 | --- Display an error message and exit. |
| 10 | -- @param message string: The error message. | 11 | -- @param message string: The error message. |
| @@ -50,16 +51,20 @@ function run_command(...) | |||
| 50 | end | 51 | end |
| 51 | local root_dir = fs.absolute_name(flags["to"]) | 52 | local root_dir = fs.absolute_name(flags["to"]) |
| 52 | cfg.root_dir = root_dir | 53 | cfg.root_dir = root_dir |
| 53 | cfg.rocks_dir = root_dir.."/rocks" | 54 | cfg.rocks_dir = path.rocks_dir(root_dir) |
| 54 | cfg.scripts_dir = root_dir.."/bin" | 55 | cfg.scripts_dir = path.scripts_dir(root_dir) |
| 56 | cfg.lua_modules_dir = path.lua_modules_dir(root_dir) | ||
| 57 | cfg.bin_modules_dir = path.bin_modules_dir(root_dir) | ||
| 55 | else | 58 | else |
| 56 | local trees = cfg.rocks_trees | 59 | local trees = cfg.rocks_trees |
| 57 | for i = #trees, 1, -1 do | 60 | for i = #trees, 1, -1 do |
| 58 | local tree = trees[i] | 61 | local tree = trees[i] |
| 59 | if fs.make_dir(tree) and fs.is_writable(tree) then | 62 | if fs.make_dir(tree) and fs.is_writable(tree) then |
| 60 | cfg.root_dir = tree | 63 | cfg.root_dir = tree |
| 61 | cfg.rocks_dir = tree.."/rocks" | 64 | cfg.rocks_dir = path.rocks_dir(tree) |
| 62 | cfg.scripts_dir = rawget(cfg, "scripts_dir") or tree.."/bin" | 65 | cfg.scripts_dir = rawget(cfg, "scripts_dir") or path.scripts_dir(tree) |
| 66 | cfg.lua_modules_dir = rawget(cfg, "lua_modules_dir") or path.lua_modules_dir(tree) | ||
| 67 | cfg.bin_modules_dir = rawget(cfg, "bin_modules_dir") or path.bin_modules_dir(tree) | ||
| 63 | break | 68 | break |
| 64 | end | 69 | end |
| 65 | end | 70 | end |
| @@ -68,6 +73,8 @@ function run_command(...) | |||
| 68 | cfg.root_dir = cfg.root_dir:gsub("/+$", "") | 73 | cfg.root_dir = cfg.root_dir:gsub("/+$", "") |
| 69 | cfg.rocks_dir = cfg.rocks_dir:gsub("/+$", "") | 74 | cfg.rocks_dir = cfg.rocks_dir:gsub("/+$", "") |
| 70 | cfg.scripts_dir = cfg.scripts_dir:gsub("/+$", "") | 75 | cfg.scripts_dir = cfg.scripts_dir:gsub("/+$", "") |
| 76 | cfg.lua_modules_dir = cfg.lua_modules_dir:gsub("/+$", "") | ||
| 77 | cfg.bin_modules_dir = cfg.bin_modules_dir:gsub("/+$", "") | ||
| 71 | 78 | ||
| 72 | cfg.variables.ROCKS_TREE = cfg.root_dir | 79 | cfg.variables.ROCKS_TREE = cfg.root_dir |
| 73 | cfg.variables.SCRIPTS_DIR = cfg.scripts_dir | 80 | cfg.variables.SCRIPTS_DIR = cfg.scripts_dir |
