diff options
Diffstat (limited to 'src/luarocks/path.lua')
-rw-r--r-- | src/luarocks/path.lua | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index fe241aa5..8c795e8b 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
@@ -193,22 +193,18 @@ function bin_dir(name, version, repo) | |||
193 | return dir.path(rocks_dir(repo), name, version, "bin") | 193 | return dir.path(rocks_dir(repo), name, version, "bin") |
194 | end | 194 | end |
195 | 195 | ||
196 | --- Extract name, version and arch of a rock filename. | 196 | --- Extract name, version and arch of a rock filename, |
197 | -- @param rock_file string: pathname of a rock | 197 | -- or name, version and "rockspec" from a rockspec name. |
198 | -- @param file_name string: pathname of a rock or rockspec | ||
198 | -- @return (string, string, string) or nil: name, version and arch | 199 | -- @return (string, string, string) or nil: name, version and arch |
199 | -- of rock, or nil if name could not be parsed | 200 | -- or nil if name could not be parsed |
200 | function parse_rock_name(rock_file) | 201 | function parse_name(file_name) |
201 | assert(type(rock_file) == "string") | 202 | assert(type(file_name) == "string") |
202 | return dir.base_name(rock_file):match("(.*)-([^-]+-%d+)%.([^.]+)%.rock$") | 203 | if file_name:match("%.rock$") then |
203 | end | 204 | return dir.base_name(file_name):match("(.*)-([^-]+-%d+)%.([^.]+)%.rock$") |
204 | 205 | else | |
205 | --- Extract name and version of a rockspec filename. | 206 | return dir.base_name(file_name):match("(.*)-([^-]+-%d+)%.(rockspec)") |
206 | -- @param rockspec_file string: pathname of a rockspec | 207 | end |
207 | -- @return (string, string) or nil: name and version | ||
208 | -- of rockspec, or nil if name could not be parsed | ||
209 | function parse_rockspec_name(rockspec_file) | ||
210 | assert(type(rockspec_file) == "string") | ||
211 | return dir.base_name(rockspec_file):match("(.*)-([^-]+-%d+)%.(rockspec)") | ||
212 | end | 208 | end |
213 | 209 | ||
214 | --- Make a rockspec or rock URL. | 210 | --- Make a rockspec or rock URL. |
@@ -301,6 +297,14 @@ function versioned_name(file, prefix, name, version) | |||
301 | return dir.path(prefix, name_version.."-"..rest) | 297 | return dir.path(prefix, name_version.."-"..rest) |
302 | end | 298 | end |
303 | 299 | ||
300 | function use_tree(tree) | ||
301 | cfg.root_dir = tree | ||
302 | cfg.rocks_dir = rocks_dir(tree) | ||
303 | cfg.deploy_bin_dir = deploy_bin_dir(tree) | ||
304 | cfg.deploy_lua_dir = deploy_lua_dir(tree) | ||
305 | cfg.deploy_lib_dir = deploy_lib_dir(tree) | ||
306 | end | ||
307 | |||
304 | --- Driver function for "path" command. | 308 | --- Driver function for "path" command. |
305 | -- @return boolean This function always succeeds. | 309 | -- @return boolean This function always succeeds. |
306 | function run(...) | 310 | function run(...) |