Comparison

util/dependencies.lua @ 13114:025c38ee885d

util.dependencies: Print tables itself to reduce number of imports Rationale: See diffstat When this module is imported, it ends up calling stty via term_width() in util.human.io.table(). When this happens outside of a terminal, the following message is sent to stdout: stty: 'standard input': Inappropriate ioctl for device Not importing this module avoids that. Furthermore three is value in this module having minimal dependencies as they might not be available when it does the checks. Ref a1fed82c44b9
author Kim Alvefur <zash@zash.se>
date Fri, 26 May 2023 21:18:27 +0200
parent 12975:d10957394a3c
comparison
equal deleted inserted replaced
13113:191fe4866e3e 13114:025c38ee885d
5 -- This project is MIT/X11 licensed. Please see the 5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information. 6 -- COPYING file in the source package for more information.
7 -- 7 --
8 8
9 local function softreq(...) local ok, lib = pcall(require, ...); if ok then return lib; else return nil, lib; end end 9 local function softreq(...) local ok, lib = pcall(require, ...); if ok then return lib; else return nil, lib; end end
10 local platform_table = require "prosody.util.human.io".table({ { width = 15, align = "right" }, { width = "100%" } });
11 10
12 -- Required to be able to find packages installed with luarocks 11 -- Required to be able to find packages installed with luarocks
13 if not softreq "luarocks.loader" then -- LuaRocks 2.x 12 if not softreq "luarocks.loader" then -- LuaRocks 2.x
14 softreq "luarocks.require"; -- LuaRocks <1.x 13 softreq "luarocks.require"; -- LuaRocks <1.x
15 end 14 end
20 print("**************************"); 19 print("**************************");
21 print("Prosody was unable to find "..tostring(name)); 20 print("Prosody was unable to find "..tostring(name));
22 print("This package can be obtained in the following ways:"); 21 print("This package can be obtained in the following ways:");
23 print(""); 22 print("");
24 for _, row in ipairs(sources) do 23 for _, row in ipairs(sources) do
25 print(platform_table(row)); 24 print(string.format("%15s | %s", table.unpack(row)));
26 end 25 end
27 print(""); 26 print("");
28 print(msg or (name.." is required for Prosody to run, so we will now exit.")); 27 print(msg or (name.." is required for Prosody to run, so we will now exit."));
29 print("More help can be found on our website, at https://prosody.im/doc/depends"); 28 print("More help can be found on our website, at https://prosody.im/doc/depends");
30 print("**************************"); 29 print("**************************");