aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Melnichenko <mpeterval@gmail.com>2016-11-05 12:25:20 +0300
committerPeter Melnichenko <mpeterval@gmail.com>2016-11-05 12:25:20 +0300
commitebc8644e8bb8e04eb29d874ffa8dd48af8cfa482 (patch)
tree0da1b76bc361991a00ddb14c029edccecf66b224 /src
parent6606ae90f54bc142a2129f491b0aad8e7352b18d (diff)
downloadluarocks-ebc8644e8bb8e04eb29d874ffa8dd48af8cfa482.tar.gz
luarocks-ebc8644e8bb8e04eb29d874ffa8dd48af8cfa482.tar.bz2
luarocks-ebc8644e8bb8e04eb29d874ffa8dd48af8cfa482.zip
luarocks.repos: refactor recurse_rock_manifest_tree
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/repos.lua34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua
index 41e8f344..4ef43867 100644
--- a/src/luarocks/repos.lua
+++ b/src/luarocks/repos.lua
@@ -54,31 +54,31 @@ end
54local function recurse_rock_manifest_tree(file_tree, action) 54local function recurse_rock_manifest_tree(file_tree, action)
55 assert(type(file_tree) == "table") 55 assert(type(file_tree) == "table")
56 assert(type(action) == "function") 56 assert(type(action) == "function")
57 local function do_recurse_rock_manifest_tree(tree, parent_path, parent_module) 57
58 58 local function do_recurse_rock_manifest_tree(tree, parent_path)
59 for file, sub in pairs(tree) do 59 for file, sub in pairs(tree) do
60 local sub_path = (parent_path and (parent_path .. "/") or "") .. file
61 local ok, err
62
60 if type(sub) == "table" then 63 if type(sub) == "table" then
61 local ok, err = do_recurse_rock_manifest_tree(sub, parent_path..file.."/", parent_module..file..".") 64 ok, err = do_recurse_rock_manifest_tree(sub, sub_path)
62 if not ok then return nil, err end
63 else 65 else
64 local ok, err = action(parent_path, parent_module, file) 66 ok, err = action(sub_path)
65 if not ok then return nil, err end
66 end 67 end
68
69 if not ok then return nil, err end
67 end 70 end
68 return true 71 return true
69 end 72 end
70 return do_recurse_rock_manifest_tree(file_tree, "", "") 73 return do_recurse_rock_manifest_tree(file_tree)
71end 74end
72 75
73local function store_package_data(result, name, file_tree) 76local function store_package_data(result, name, file_tree)
74 if not file_tree then return end 77 if not file_tree then return end
75 return recurse_rock_manifest_tree(file_tree, 78 return recurse_rock_manifest_tree(file_tree, function(file_path)
76 function(parent_path, parent_module, file) 79 result[path.path_to_module(file_path)] = file_path
77 local pathname = parent_path..file 80 return true
78 result[path.path_to_module(pathname)] = pathname 81 end)
79 return true
80 end
81 )
82end 82end
83 83
84--- Obtain a list of modules within an installed package. 84--- Obtain a list of modules within an installed package.
@@ -279,8 +279,7 @@ function repos.deploy_files(name, version, wrap_bin_scripts, deps_mode)
279 return true 279 return true
280 end 280 end
281 281
282 return recurse_rock_manifest_tree(rock_manifest[deploy_type], function(parent_path, parent_module, file) 282 return recurse_rock_manifest_tree(rock_manifest[deploy_type], function(file_path)
283 local file_path = parent_path .. file
284 local source = dir.path(source_dir, file_path) 283 local source = dir.path(source_dir, file_path)
285 284
286 local target, prepare_err = prepare_target(name, version, deploy_type, file_path, suffix) 285 local target, prepare_err = prepare_target(name, version, deploy_type, file_path, suffix)
@@ -359,8 +358,7 @@ function repos.delete_version(name, version, deps_mode, quick)
359 return true 358 return true
360 end 359 end
361 360
362 return recurse_rock_manifest_tree(rock_manifest[deploy_type], function(parent_path, parent_module, file) 361 return recurse_rock_manifest_tree(rock_manifest[deploy_type], function(file_path)
363 local file_path = parent_path .. file
364 local non_versioned, versioned = get_deploy_paths(name, version, deploy_type, file_path) 362 local non_versioned, versioned = get_deploy_paths(name, version, deploy_type, file_path)
365 363
366 -- Figure out if the file is deployed using versioned or non-versioned name. 364 -- Figure out if the file is deployed using versioned or non-versioned name.