diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-29 00:46:06 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-29 15:46:16 +0000 |
| commit | f76b7a2b13e411df2e696146bb0a6396781acd92 (patch) | |
| tree | 38ed32f81f05f6eacd03f36eacd5341e7b1d17dd /src | |
| parent | 0ca8c460e867356342180bb625760ed9201a5503 (diff) | |
| download | luarocks-f76b7a2b13e411df2e696146bb0a6396781acd92.tar.gz luarocks-f76b7a2b13e411df2e696146bb0a6396781acd92.tar.bz2 luarocks-f76b7a2b13e411df2e696146bb0a6396781acd92.zip | |
tests: speed up and simplify
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/cmd.lua | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 452237d2..200ec13b 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
| @@ -63,6 +63,19 @@ do | |||
| 63 | cfg.deploy_lib_dir = cfg.deploy_lib_dir:gsub("/+$", "") | 63 | cfg.deploy_lib_dir = cfg.deploy_lib_dir:gsub("/+$", "") |
| 64 | end | 64 | end |
| 65 | 65 | ||
| 66 | local function set_named_tree(args, name) | ||
| 67 | for _, tree in ipairs(cfg.rocks_trees) do | ||
| 68 | if type(tree) == "table" and name == tree.name then | ||
| 69 | if not tree.root then | ||
| 70 | return nil, "Configuration error: tree '"..tree.name.."' has no 'root' field." | ||
| 71 | end | ||
| 72 | replace_tree(args, tree.root, tree) | ||
| 73 | return true | ||
| 74 | end | ||
| 75 | end | ||
| 76 | return false | ||
| 77 | end | ||
| 78 | |||
| 66 | process_tree_args = function(args, project_dir) | 79 | process_tree_args = function(args, project_dir) |
| 67 | 80 | ||
| 68 | if args.global then | 81 | if args.global then |
| @@ -70,17 +83,7 @@ do | |||
| 70 | end | 83 | end |
| 71 | 84 | ||
| 72 | if args.tree then | 85 | if args.tree then |
| 73 | local named = false | 86 | local named = set_named_tree(args, args.tree) |
| 74 | for _, tree in ipairs(cfg.rocks_trees) do | ||
| 75 | if type(tree) == "table" and args.tree == tree.name then | ||
| 76 | if not tree.root then | ||
| 77 | return nil, "Configuration error: tree '"..tree.name.."' has no 'root' field." | ||
| 78 | end | ||
| 79 | replace_tree(args, tree.root, tree) | ||
| 80 | named = true | ||
| 81 | break | ||
| 82 | end | ||
| 83 | end | ||
| 84 | if not named then | 87 | if not named then |
| 85 | local root_dir = fs.absolute_name(args.tree) | 88 | local root_dir = fs.absolute_name(args.tree) |
| 86 | replace_tree(args, root_dir) | 89 | replace_tree(args, root_dir) |
| @@ -94,7 +97,7 @@ do | |||
| 94 | "You are running as a superuser, which is intended for system-wide operation.\n".. | 97 | "You are running as a superuser, which is intended for system-wide operation.\n".. |
| 95 | "To force using the superuser's home, use --tree explicitly." | 98 | "To force using the superuser's home, use --tree explicitly." |
| 96 | else | 99 | else |
| 97 | replace_tree(args, cfg.home_tree) | 100 | set_named_tree(args, "user") |
| 98 | end | 101 | end |
| 99 | elseif args.project_tree then | 102 | elseif args.project_tree then |
| 100 | local tree = args.project_tree | 103 | local tree = args.project_tree |
| @@ -102,9 +105,7 @@ do | |||
| 102 | manif.load_rocks_tree_manifests() | 105 | manif.load_rocks_tree_manifests() |
| 103 | path.use_tree(tree) | 106 | path.use_tree(tree) |
| 104 | elseif cfg.local_by_default then | 107 | elseif cfg.local_by_default then |
| 105 | if cfg.home_tree then | 108 | set_named_tree(args, "user") |
| 106 | replace_tree(args, cfg.home_tree) | ||
| 107 | end | ||
| 108 | elseif project_dir then | 109 | elseif project_dir then |
| 109 | local project_tree = project_dir .. "/lua_modules" | 110 | local project_tree = project_dir .. "/lua_modules" |
| 110 | table.insert(cfg.rocks_trees, 1, { name = "project", root = project_tree } ) | 111 | table.insert(cfg.rocks_trees, 1, { name = "project", root = project_tree } ) |
