diff options
| author | ruki <[email protected]> | 2017-09-21 00:37:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-09-20 21:45:03 +0800 |
| commit | 253e814d11d2af31088a22401a28b4a6abef70e3 (patch) | |
| tree | 18e357e181a7d43217ca943c02a31fa5648e4d88 | |
| parent | 7d95839ada4f468a2fd0c1cbe13febfb7dde146a (diff) | |
fix install required packages bug
| -rw-r--r-- | xmake/actions/require/install.lua | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/xmake/actions/require/install.lua b/xmake/actions/require/install.lua index 865cd2c4d..1cdc406df 100644 --- a/xmake/actions/require/install.lua +++ b/xmake/actions/require/install.lua @@ -101,16 +101,25 @@ end -- get user confirm function _get_confirm(packages) + -- init confirmed packages + local confirmed_packages = {} + for _, instance in ipairs(packages) do + if (option.get("force") or not instance:exists()) and (#instance:urls() > 0 or instance:script("install")) then + table.insert(confirmed_packages, instance) + end + end + if #confirmed_packages == 0 then + return true + end + -- get confirm local confirm = option.get("yes") if confirm == nil then -- show tips cprint("${bright yellow}note: ${default yellow}try installing all required packages (pass -y to skip confirm)?") - for _, instance in ipairs(packages) do - if (option.get("force") or not instance:exists()) and (#instance:urls() > 0 or instance:script("install")) then - print(" -> %s %s", instance:fullname(), instance:version_str() or "") - end + for _, instance in ipairs(confirmed_packages) do + print(" -> %s %s", instance:fullname(), instance:version_str() or "") end cprint("please input: y (y/n)") @@ -211,6 +220,9 @@ function _install_packages(requires) action.install(instance) end end + + -- ok + return packages end -- install packages @@ -230,13 +242,15 @@ function main(requires) end -- install packages - _install_packages(requires) + local packages = _install_packages(requires) + if packages then - -- check missing packages - _check_missing_packages(packages) + -- check missing packages + _check_missing_packages(packages) - -- attach required local package to targets - _attach_to_targets(packages) + -- attach required local package to targets + _attach_to_targets(packages) + end -- leave environment environment.leave() |
