Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
19 changes: 10 additions & 9 deletions crates/vite_task/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Str>,

#[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<Str>,

/// 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`
///
/// <https://github.com/voidzero-dev/vite-task/issues/285>
#[clap(trailing_var_arg = true, allow_hyphen_values = true)]
pub(crate) task_and_args: Vec<Str>,
}

/// vite task CLI subcommands as parsed by clap.
Expand Down Expand Up @@ -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(),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -15,7 +15,7 @@ $ vt lint -D no-debugger
Found 0 warnings and 1 error.
Finished in <duration> on 1 file with 93 rules using <n> 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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"scripts": {
"echo": "echo"
}
}
Original file line number Diff line number Diff line change
@@ -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`
]
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cache": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <TASK_SPECIFIER> [ADDITIONAL_ARGS]...
Usage: vt run --cache <TASK_AND_ARGS>...

For more information, try '--help'.