diff options
-rw-r--r-- | src/luarocks/fs.lua | 16 |
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 | ||
19 | math.randomseed(os.time()) | 19 | math.randomseed(os.time()) |
20 | 20 | ||
21 | local fs_is_verbose = false | ||
22 | |||
21 | do | 23 | do |
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 |