diff options
| author | ruki <[email protected]> | 2022-07-23 11:21:32 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-07-23 11:21:32 +0800 |
| commit | 9d575f566d326a83137d48fe2e277b2d95cca235 (patch) | |
| tree | fda0ed201205e2d4caa7eafbeb778263f2291c7a | |
| parent | 8b77ddb098cd070779af0258db1f6e984d388130 (diff) | |
improve watch
| -rw-r--r-- | xmake/plugins/watch/main.lua | 10 | ||||
| -rw-r--r-- | xmake/plugins/watch/xmake.lua | 3 |
2 files changed, 9 insertions, 4 deletions
diff --git a/xmake/plugins/watch/main.lua b/xmake/plugins/watch/main.lua index f1fc4cd3d..7dd30d66d 100644 --- a/xmake/plugins/watch/main.lua +++ b/xmake/plugins/watch/main.lua @@ -64,12 +64,18 @@ function _run_command() for _, command in ipairs(command:split(";")) do os.exec(command) end - elseif os.isfile(scriptfile) and path.extension(scriptfile) == ".lua" then + 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() elseif os.isfile(os.projectfile()) then - os.execv(os.programfile(), {"build", "-w"}) + local argv = {"build"} + table.insert(argv, "-w") + local target = option.get("target") + if target then + table.insert(argv, target) + end + os.execv(os.programfile(), argv) end end, catch diff --git a/xmake/plugins/watch/xmake.lua b/xmake/plugins/watch/xmake.lua index 9d2f8b5ce..c35db328c 100644 --- a/xmake/plugins/watch/xmake.lua +++ b/xmake/plugins/watch/xmake.lua @@ -37,8 +37,7 @@ task("watch") "e.g.", " $ xmake watch -d src", " $ xmake watch -d 'src/*" .. path.envsep() .. "tests/**/subdir'"}, - {'r', "recursion" , "k" , nil , "Recursively watch directories."}, - {'t', "target" , "kv" , nil , "Build the given target.", + {'t', "target" , "v" , nil , "Build the given target.", values = function (complete, opt) return import("private.utils.complete_helper.targets")(complete, opt) end } } } |
