From 41b4b3f5cd9dfc65beed40ba9e2e9d4f41c50b7a Mon Sep 17 00:00:00 2001 From: Liang Mi Date: Sun, 22 Mar 2026 15:05:31 +0800 Subject: [PATCH 1/5] fix: prevent args to the task being consumed by vp --- crates/vite_task/src/cli/mod.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/crates/vite_task/src/cli/mod.rs b/crates/vite_task/src/cli/mod.rs index 35b32a0c..dd4605e7 100644 --- a/crates/vite_task/src/cli/mod.rs +++ b/crates/vite_task/src/cli/mod.rs @@ -76,19 +76,19 @@ impl RunFlags { /// `ResolvedCommand::RunLastDetails` variant internally. #[derive(Debug, clap::Parser)] pub struct RunCommand { - /// `packageName#taskName` or `taskName`. If omitted, lists all available tasks. - pub(crate) task_specifier: Option, - #[clap(flatten)] pub(crate) flags: RunFlags, - /// Additional arguments to pass to the tasks - #[clap(trailing_var_arg = true, allow_hyphen_values = true)] - pub(crate) additional_args: Vec, - /// Display the detailed summary of the last run. #[clap(long, exclusive = true)] pub(crate) last_details: bool, + + /// The task name and all arguments to pass to the task process + /// Prevent flags after the task name to be consumed by Vite Task with `trailing_var_arg` + /// + /// + #[clap(trailing_var_arg = true, allow_hyphen_values = true)] + pub(crate) task_and_args: Vec, } /// vite task CLI subcommands as parsed by clap. @@ -162,10 +162,11 @@ impl RunCommand { /// Convert to the resolved run command, stripping the `last_details` flag. #[must_use] pub(crate) fn into_resolved(self) -> ResolvedRunCommand { + let mut iter = self.task_and_args.into_iter(); ResolvedRunCommand { - task_specifier: self.task_specifier, + task_specifier: iter.next(), flags: self.flags, - additional_args: self.additional_args, + additional_args: iter.collect(), } } } From 1b80bbb079186ed0d6597aa679775aba0a9bf512 Mon Sep 17 00:00:00 2001 From: Liang Mi Date: Sun, 22 Mar 2026 15:25:20 +0800 Subject: [PATCH 2/5] tests --- .../fixtures/pass-args-to-task/package.json | 5 +++++ .../fixtures/pass-args-to-task/snapshots.toml | 11 +++++++++++ .../snapshots/pass args to task.snap | 16 ++++++++++++++++ .../fixtures/pass-args-to-task/vite-task.json | 3 +++ 4 files changed, 35 insertions(+) create mode 100644 crates/vite_task_bin/tests/e2e_snapshots/fixtures/pass-args-to-task/package.json create mode 100644 crates/vite_task_bin/tests/e2e_snapshots/fixtures/pass-args-to-task/snapshots.toml create mode 100644 crates/vite_task_bin/tests/e2e_snapshots/fixtures/pass-args-to-task/snapshots/pass args to task.snap create mode 100644 crates/vite_task_bin/tests/e2e_snapshots/fixtures/pass-args-to-task/vite-task.json diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/pass-args-to-task/package.json b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/pass-args-to-task/package.json new file mode 100644 index 00000000..0e0f5335 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/pass-args-to-task/package.json @@ -0,0 +1,5 @@ +{ + "scripts": { + "echo": "echo" + } +} diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/pass-args-to-task/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/pass-args-to-task/snapshots.toml new file mode 100644 index 00000000..1f314994 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/pass-args-to-task/snapshots.toml @@ -0,0 +1,11 @@ +# Tests that arguments after task name should be passed to the task +# https://github.com/voidzero-dev/vite-task/issues/285 + +[[e2e]] +name = "pass args to task" +steps = [ + "vt run echo --help", # Should just print `help` instead of Vite task's help + "vt run echo --version", # Should just print `version` instead of Vite task's version + "vt run echo -v", # Should just print `-v` + "vt run echo -a", # Should just print `-a` +] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/pass-args-to-task/snapshots/pass args to task.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/pass-args-to-task/snapshots/pass args to task.snap new file mode 100644 index 00000000..b67cb323 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/pass-args-to-task/snapshots/pass args to task.snap @@ -0,0 +1,16 @@ +--- +source: crates/vite_task_bin/tests/e2e_snapshots/main.rs +expression: e2e_outputs +--- +> vt run echo --help +$ echo --help ⊘ cache disabled +--help +> vt run echo --version +$ echo --version ⊘ cache disabled +--version +> vt run echo -v +$ echo -v ⊘ cache disabled +-v +> vt run echo -a +$ echo -a ⊘ cache disabled +-a diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/pass-args-to-task/vite-task.json b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/pass-args-to-task/vite-task.json new file mode 100644 index 00000000..b39113d0 --- /dev/null +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/pass-args-to-task/vite-task.json @@ -0,0 +1,3 @@ +{ + "cache": false +} From aff4ae2743892b064b8a9c3d06a936c4a3c538dc Mon Sep 17 00:00:00 2001 From: Liang Mi Date: Sun, 22 Mar 2026 15:26:57 +0800 Subject: [PATCH 3/5] docs --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 144eeab2..a3cee071 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ Install [Vite+](https://viteplus.dev), then run tasks from your workspace. See t ```bash vp run build # run a task in the current package -vp run build -r # run across all packages in dependency order -vp run @my/app#build -t # run in a package and its transitive dependencies +vp run -r build # run across all packages in dependency order +vp run -t @my/app#build # run in a package and its transitive dependencies vp run --cache build # run with caching enabled ``` From edcf44ebd4607122923845bcb998df5677b5aa99 Mon Sep 17 00:00:00 2001 From: Liang Mi Date: Sun, 22 Mar 2026 15:30:23 +0800 Subject: [PATCH 4/5] updated related test snapshots --- ...o exit does not show cache not updated.snap | 4 ++-- ...test prints value from additional_envs.snap | 2 +- .../env-test with different values.snap | 4 ++-- .../fixtures/task-select/snapshots.toml | 2 +- .../verbose with typo enters selector.snap | 18 ++---------------- ...uery - --cache and --no-cache conflict.snap | 2 +- 6 files changed, 9 insertions(+), 23 deletions(-) diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-non-zero-exit/snapshots/builtin command with non-zero exit does not show cache not updated.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-non-zero-exit/snapshots/builtin command with non-zero exit does not show cache not updated.snap index 81774f05..b74a8fc0 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-non-zero-exit/snapshots/builtin command with non-zero exit does not show cache not updated.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-non-zero-exit/snapshots/builtin command with non-zero exit does not show cache not updated.snap @@ -3,7 +3,7 @@ source: crates/vite_task_bin/tests/e2e_snapshots/main.rs expression: e2e_outputs --- [1]> vt run lint -- -D no-debugger -$ vt lint -D no-debugger +$ vt lint -- -D no-debugger x eslint(no-debugger): `debugger` statement is not allowed ,-[bad.js:1:1] @@ -15,7 +15,7 @@ $ vt lint -D no-debugger Found 0 warnings and 1 error. Finished in on 1 file with 93 rules using threads. [1]> vt run lint -- -D no-debugger -$ vt lint -D no-debugger +$ vt lint -- -D no-debugger x eslint(no-debugger): `debugger` statement is not allowed ,-[bad.js:1:1] diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots/env-test prints value from additional_envs.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots/env-test prints value from additional_envs.snap index 953cca78..c2f767bb 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots/env-test prints value from additional_envs.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots/env-test prints value from additional_envs.snap @@ -3,5 +3,5 @@ source: crates/vite_task_bin/tests/e2e_snapshots/main.rs expression: e2e_outputs --- > vt run env-test -- SYNTHETIC_ENV_VAR test_value_from_synthesizer # prints env value -$ vt env-test SYNTHETIC_ENV_VAR test_value_from_synthesizer +$ vt env-test -- SYNTHETIC_ENV_VAR test_value_from_synthesizer test_value_from_synthesizer diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots/env-test with different values.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots/env-test with different values.snap index 7b5c67fc..83de9cad 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots/env-test with different values.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/e2e-env-test/snapshots/env-test with different values.snap @@ -3,8 +3,8 @@ source: crates/vite_task_bin/tests/e2e_snapshots/main.rs expression: e2e_outputs --- > vt run env-test -- FOO bar # sets FOO=bar -$ vt env-test FOO bar +$ vt env-test -- FOO bar bar > vt run env-test -- BAZ qux # sets BAZ=qux -$ vt env-test BAZ qux +$ vt env-test -- BAZ qux qux diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-select/snapshots.toml b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-select/snapshots.toml index 115ea39f..77d6d154 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-select/snapshots.toml +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-select/snapshots.toml @@ -214,7 +214,7 @@ steps = ["vt run --verbose"] name = "verbose with typo enters selector" cwd = "packages/app" steps = [ - { command = "vt run buid --verbose", interactions = [ + { command = "vt run --verbose buid", interactions = [ { "expect-milestone" = "task-select:buid:0" }, { "write-key" = "enter" }, ] }, diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-select/snapshots/verbose with typo enters selector.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-select/snapshots/verbose with typo enters selector.snap index dc2c457e..97d9b1db 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-select/snapshots/verbose with typo enters selector.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-select/snapshots/verbose with typo enters selector.snap @@ -14,19 +14,5 @@ Select a task (↑/↓, Enter to run, type to search): buid build echo build lib @ write-key: enter Selected task: build -~/packages/app$ echo build app ⊘ cache disabled -build app - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - Vite+ Task Runner • Execution Summary -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -Statistics: 1 tasks • 0 cache hits • 0 cache misses • 1 cache disabled -Performance: 0% cache hit rate - -Task Details: -──────────────────────────────────────────────── - [1] app#build: ~/packages/app$ echo build app ✓ - → Cache disabled for built-in command -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +~/packages/app$ echo build app --verbose ⊘ cache disabled +build app --verbose diff --git a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache and --no-cache conflict.snap b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache and --no-cache conflict.snap index ef47908e..f2467331 100644 --- a/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache and --no-cache conflict.snap +++ b/crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-override/snapshots/query - --cache and --no-cache conflict.snap @@ -11,6 +11,6 @@ input_file: crates/vite_task_plan/tests/plan_snapshots/fixtures/cache-cli-overri --- error: the argument '--cache' cannot be used with '--no-cache' -Usage: vt run --cache [ADDITIONAL_ARGS]... +Usage: vt run --cache ... For more information, try '--help'. From f6fd4f66619695f8c56c13ceeb9d43b7bcb052ee Mon Sep 17 00:00:00 2001 From: Liang Mi Date: Sun, 22 Mar 2026 19:06:45 +0800 Subject: [PATCH 5/5] update snapshots, fix ci --- .../verbose with typo enters selector.snap | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-select/snapshots/verbose with typo enters selector.snap b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-select/snapshots/verbose with typo enters selector.snap index 97d9b1db..bc084185 100644 --- a/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-select/snapshots/verbose with typo enters selector.snap +++ b/crates/vite_task_bin/tests/e2e_snapshots/fixtures/task-select/snapshots/verbose with typo enters selector.snap @@ -4,7 +4,7 @@ expression: e2e_outputs info: cwd: packages/app --- -> vt run buid --verbose +> vt run --verbose buid @ expect-milestone: task-select:buid:0 Task "buid" not found. Select a task (↑/↓, Enter to run, type to search): buid @@ -14,5 +14,19 @@ Select a task (↑/↓, Enter to run, type to search): buid build echo build lib @ write-key: enter Selected task: build -~/packages/app$ echo build app --verbose ⊘ cache disabled -build app --verbose +~/packages/app$ echo build app ⊘ cache disabled +build app + + +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + Vite+ Task Runner • Execution Summary +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Statistics: 1 tasks • 0 cache hits • 0 cache misses • 1 cache disabled +Performance: 0% cache hit rate + +Task Details: +──────────────────────────────────────────────── + [1] app#build: ~/packages/app$ echo build app ✓ + → Cache disabled for built-in command +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━