summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-07-28 22:32:32 +0800
committerruki <[email protected]>2022-07-28 22:32:32 +0800
commit0260cf0c08efd022be56cb81c460b932a27f4fa8 (patch)
treede119a0c460ae8291773ce8442485df61e0a7871
parent977dc2010cfff4ae1784a2481df33a9217703a01 (diff)
pass events to watch scripts
-rw-r--r--xmake/plugins/watch/main.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/xmake/plugins/watch/main.lua b/xmake/plugins/watch/main.lua
index f7b628d0c..e5fadad3b 100644
--- a/xmake/plugins/watch/main.lua
+++ b/xmake/plugins/watch/main.lua
@@ -54,7 +54,7 @@ function _add_watchdirs()
end
-- run command
-function _run_command()
+function _run_command(events)
try
{
function ()
@@ -72,7 +72,7 @@ function _run_command()
elseif scriptfile and os.isfile(scriptfile) and path.extension(scriptfile) == ".lua" then
local script = import(path.basename(scriptfile),
{rootdir = path.directory(scriptfile), anonymous = true})
- script()
+ script(events)
elseif os.isfile(os.projectfile()) then
local argv = {"build", "-y"}
if option.get("verbose") then
@@ -111,6 +111,7 @@ function main()
-- do watch
local count = 0
+ local events = {}
while true do
local ok, event = fwatcher.wait(300)
if ok > 0 then
@@ -123,9 +124,10 @@ function main()
status = "deleted"
end
print(event.path, status)
+ table.insert(events, event)
count = count + 1
elseif count > 0 then
- _run_command()
+ _run_command(events)
count = 0
end
end