summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-07-28 22:36:01 +0800
committerruki <[email protected]>2022-07-28 22:36:01 +0800
commit540ebd93b1fcec450ae81e3e95637b6dc0d051b5 (patch)
treedb2c5c1f92d8576ecb2e8d611b0d91685de0b4c4
parent0260cf0c08efd022be56cb81c460b932a27f4fa8 (diff)
improve watch
-rw-r--r--xmake/plugins/watch/main.lua18
-rw-r--r--xmake/plugins/watch/xmake.lua6
2 files changed, 19 insertions, 5 deletions
diff --git a/xmake/plugins/watch/main.lua b/xmake/plugins/watch/main.lua
index e5fadad3b..3293296fa 100644
--- a/xmake/plugins/watch/main.lua
+++ b/xmake/plugins/watch/main.lua
@@ -33,10 +33,20 @@ end
-- add watchdirs
function _add_watchdirs()
local watchdirs = option.get("watchdirs")
- if watchdirs then
- for _, watchdir in ipairs(path.splitenv(watchdirs)) do
- for _, dir in ipairs(os.dirs(watchdir)) do
- _add_watchdir(dir, {recursion = true})
+ local plaindirs = option.get("plaindirs")
+ if watchdirs or plaindirs then
+ if watchdirs then
+ for _, watchdir in ipairs(path.splitenv(watchdirs)) do
+ for _, dir in ipairs(os.dirs(watchdir)) do
+ _add_watchdir(dir, {recursion = true})
+ end
+ end
+ end
+ if plaindirs then
+ for _, watchdir in ipairs(path.splitenv(plaindirs)) do
+ for _, dir in ipairs(os.dirs(watchdir)) do
+ _add_watchdir(dir)
+ end
end
end
elseif os.isfile(os.projectfile()) then
diff --git a/xmake/plugins/watch/xmake.lua b/xmake/plugins/watch/xmake.lua
index 0c7ae6fde..70d2ac242 100644
--- a/xmake/plugins/watch/xmake.lua
+++ b/xmake/plugins/watch/xmake.lua
@@ -33,10 +33,14 @@ task("watch")
{'s', "script" , "kv" , nil , "Run the given lua script file.",
"e.g.",
" $ xmake watch -s /tmp/watch.lua"},
- {'d', "watchdirs" , "kv" , nil , "Set the given watch directories, the project directories will be watched by default.",
+ {'d', "watchdirs" , "kv" , nil , "Set the given recursive watch directories, the project directories will be watched by default.",
"e.g.",
" $ xmake watch -d src",
" $ xmake watch -d 'src/*" .. path.envsep() .. "tests/**/subdir'"},
+ {'p', "plaindirs" , "kv" , nil , "Set the given non-recursive watch directories, the project directories will be watched by default.",
+ "e.g.",
+ " $ xmake watch -D src",
+ " $ xmake watch -D 'src/*" .. path.envsep() .. "tests/**/subdir'"},
{'r', "run" , "k" , nil , "Build and run target."},
{'t', "target" , "kv" , nil , "Build the given target.",
values = function (complete, opt) return import("private.utils.complete_helper.targets")(complete, opt) end },