import("core.base.fwatcher")
-- listen file change
-- use xmake watch plugin and fwatcher to replace file mtime
fwatcher.add(os.projectdir(), {recursive = true})
local function target_files_changed()
local ok, event = fwatcher.wait(50)
local status = nil
if ok > 0 then
local status
if event.type == fwatcher.ET_CREATE then
status = "created"
elseif event.type == fwatcher.ET_MODIFY then
status = "modified"
elseif event.type == fwatcher.ET_DELETE then
status = "deleted"
end
-- print(event.path, status)
end
return status ~= nil
end
https://xmake.io/#/zh-cn/plugin/builtin_plugins?id=%e9%a1%b9%e7%9b%ae%e6%9b%b4%e6%96%b0%e5%90%8e%e8%87%aa%e5%8a%a8%e6%9e%84%e5%bb%ba