diff options
| author | ValleyKnight <[email protected]> | 2021-05-12 12:22:39 -0400 |
|---|---|---|
| committer | ValleyKnight <[email protected]> | 2021-05-12 12:22:39 -0400 |
| commit | f5a27a45d41d0d3b26a479d859a1fcdf0893b6e6 (patch) | |
| tree | e0b8b5a032fe1f036e373fba922f2d28cfeb3427 | |
| parent | 3d6d64e112f8522389aad50bc9836102df47f8c2 (diff) | |
implement some changes suggested by ruki
| -rw-r--r-- | xmake/modules/package/manager/portage/find_package.lua | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/xmake/modules/package/manager/portage/find_package.lua b/xmake/modules/package/manager/portage/find_package.lua index 9011705f5..dfb7a3b22 100644 --- a/xmake/modules/package/manager/portage/find_package.lua +++ b/xmake/modules/package/manager/portage/find_package.lua @@ -42,13 +42,14 @@ function main(name, opt) -- get package files list local file_path = "/var/db/pkg/*/" .. name .. "-*/" local file = find_file("CONTENTS", file_path) - local file_contents = try { function() return io.readfile(file) end } - -- if the file contents couldn't be obtained, the package isn't installed - if not file_contents then + -- if the file couldn't be found, then the package isn't installed + if not file then return end + local file_contents = io.readfile(file) + -- create a table for the list local list_table = {} -- split entries based on newlines @@ -63,15 +64,7 @@ function main(name, opt) end -- create an initial empty string for the list - local list = "" - for _, value in pairs(list_table) do - -- append the values of the table elements to the string along with a newline - list = list .. value .. "\n" - end - - if not list then - return - end + local list = table.concat(list_table, "\n") -- parse package files list local pkgconfig_dir = nil |
