diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2013-12-18 15:33:11 -0200 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2013-12-18 15:33:11 -0200 |
| commit | 3f67e81a25607371efde249d83f1e9521349bb19 (patch) | |
| tree | 608728664130451485629ded982377c58ab37899 /src | |
| parent | 138d823b77b9cbc30397d05286723cf499d85157 (diff) | |
| download | luarocks-3f67e81a25607371efde249d83f1e9521349bb19.tar.gz luarocks-3f67e81a25607371efde249d83f1e9521349bb19.tar.bz2 luarocks-3f67e81a25607371efde249d83f1e9521349bb19.zip | |
Add named trees, as suggested by @Tieske, plus tests.
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/command_line.lua | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index d16ef8e2..63b918b5 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua | |||
| @@ -98,9 +98,22 @@ function run_command(...) | |||
| 98 | if flags["tree"] == true or flags["tree"] == "" then | 98 | if flags["tree"] == true or flags["tree"] == "" then |
| 99 | die("Argument error: use --tree=<path>") | 99 | die("Argument error: use --tree=<path>") |
| 100 | end | 100 | end |
| 101 | local fs = require("luarocks.fs") | 101 | local named = false |
| 102 | local root_dir = fs.absolute_name(flags["tree"]) | 102 | for _, tree in ipairs(cfg.rocks_trees) do |
| 103 | path.use_tree(root_dir) | 103 | if type(tree) == "table" and flags["tree"] == tree.name then |
| 104 | if not tree.root then | ||
| 105 | die("Configuration error: tree '"..tree.name.."' has no 'root' field.") | ||
| 106 | end | ||
| 107 | path.use_tree(dir.normalize(tree.root)) | ||
| 108 | named = true | ||
| 109 | break | ||
| 110 | end | ||
| 111 | end | ||
| 112 | if not named then | ||
| 113 | local fs = require("luarocks.fs") | ||
| 114 | local root_dir = fs.absolute_name(flags["tree"]) | ||
| 115 | path.use_tree(root_dir) | ||
| 116 | end | ||
| 104 | elseif flags["local"] then | 117 | elseif flags["local"] then |
| 105 | path.use_tree(cfg.home_tree) | 118 | path.use_tree(cfg.home_tree) |
| 106 | else | 119 | else |
