-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathrefresh_action.lua
37 lines (26 loc) · 867 Bytes
/
refresh_action.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
-- this is slightly modified channel.lua.
-- it allows you to skip confirmation message on selecting channels
-- as a bonus - makes the list longer
function REFRESH_ON_INIT()
local frame = ui.GetFrame("refresh")
frame:ShowWindow(1)
local luaFolderDir = "../"
local allFileNames = scandir(luaFolderDir)
for _,fileName in pairs(allFileNames) do
ui.SysMsg("Updating: " .. luaFolderDir .. fileName);
dofile(luaFolderDir .. fileName);
end
ui.SysMsg("All Lua Files Refreshed")
end
-- Lua implementation of PHP scandir function
function scandir(directory)
local i, t, popen = 0, {}, io.popen
for filename in popen('dir "'..directory..'" /b'):lines() do
if string.find(filename, ".lua") ~= nil and filename ~= "refresh_action.lua" then
t[i] = filename
i = i + 1
end
end
return t
end
REFRESH_ON_INIT()