aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2020-01-14 18:06:16 -0300
committerHisham Muhammad <hisham@gobolinux.org>2020-01-14 21:56:55 -0300
commit6f5306ddaae3a14be5f385fa6f97546d6df9de4e (patch)
tree2facef7069a43f98c92d1636323da9dcc4db5884
parent613b66c271e8b6d4c060668bfe3ca055fc35b166 (diff)
downloadluarocks-6f5306ddaae3a14be5f385fa6f97546d6df9de4e.tar.gz
luarocks-6f5306ddaae3a14be5f385fa6f97546d6df9de4e.tar.bz2
luarocks-6f5306ddaae3a14be5f385fa6f97546d6df9de4e.zip
fs: be verbose about builtin fs functions as well
-rw-r--r--src/luarocks/fs.lua16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/luarocks/fs.lua b/src/luarocks/fs.lua
index 672d8991..54891eac 100644
--- a/src/luarocks/fs.lua
+++ b/src/luarocks/fs.lua
@@ -18,11 +18,15 @@ local unpack = table.unpack or unpack
18 18
19math.randomseed(os.time()) 19math.randomseed(os.time())
20 20
21local fs_is_verbose = false
22
21do 23do
22 local old_popen, old_execute 24 local old_popen, old_execute
23 25
24 -- patch io.popen and os.execute to display commands in verbose mode 26 -- patch io.popen and os.execute to display commands in verbose mode
25 function fs.verbose() 27 function fs.verbose()
28 fs_is_verbose = true
29
26 if old_popen or old_execute then return end 30 if old_popen or old_execute then return end
27 old_popen = io.popen 31 old_popen = io.popen
28 io.popen = function(one, two) 32 io.popen = function(one, two)
@@ -52,7 +56,17 @@ do
52 local function load_fns(fs_table, inits) 56 local function load_fns(fs_table, inits)
53 for name, fn in pairs(fs_table) do 57 for name, fn in pairs(fs_table) do
54 if name ~= "init" and not fs[name] then 58 if name ~= "init" and not fs[name] then
55 fs[name] = fn 59 fs[name] = function(...)
60 if fs_is_verbose then
61 local args = { ... }
62 for i, arg in ipairs(args) do
63 local pok, v = pcall(string.format, "%q", arg)
64 args[i] = pok and v or tostring(arg)
65 end
66 print("fs." .. name .. "(" .. table.concat(args, ", ") .. ")")
67 end
68 return fn(...)
69 end
56 end 70 end
57 end 71 end
58 if fs_table.init then 72 if fs_table.init then