Skip to content

Commit 3c1ae7e

Browse files
committed
docs: clarify task shorthand and clarify array command semantics
Move the task command shorthand description out from under the \`command\` heading to the \`tasks\` section, since it sets a task value not a command field. Add an explicit note that array commands chain sequentially like \`&&\`, not split a single command into argv tokens. https://claude.ai/code/session_01N7sZTbj8K2QYvMAWUB1Nmz
1 parent ae7bfd1 commit 3c1ae7e

1 file changed

Lines changed: 31 additions & 8 deletions

File tree

docs/config/run.md

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,33 +61,56 @@ export default defineConfig({
6161

6262
## `run.tasks`
6363

64-
- **Type:** `Record<string, TaskConfig>`
64+
- **Type:** `Record<string, TaskConfig | string | string[]>`
6565

6666
Defines tasks that can be run with `vp run <task>`.
6767

68+
As a shorthand, a task value can be a command string or an array of command strings directly:
69+
70+
```ts [vite.config.ts]
71+
tasks: {
72+
build: 'vp build',
73+
check: ['vp lint', 'vp build'],
74+
}
75+
```
76+
77+
These are equivalent to setting only `command` on a task config:
78+
79+
```ts [vite.config.ts]
80+
tasks: {
81+
build: { command: 'vp build' },
82+
check: { command: ['vp lint', 'vp build'] },
83+
}
84+
```
85+
86+
Use the object form when a task needs other fields like `cache`, `dependsOn`, `env`, or `input`.
87+
6888
### `command`
6989

7090
- **Type:** `string | string[]`
7191

72-
Defines the shell command to run for the task. An array runs each entry sequentially, equivalent to joining them with `&&`.
92+
Defines the shell command to run for the task. The string is interpreted by a shell, so spaces, quoting, `&&`, pipes, and redirects all work as written on the command line.
7393

7494
```ts [vite.config.ts]
7595
tasks: {
7696
build: {
7797
command: 'vp build',
7898
},
79-
check: {
80-
command: ['vp lint', 'vp build'],
81-
},
8299
}
83100
```
84101

85-
As a shorthand, a task value can also be a command string or array of command strings directly, without the surrounding object:
102+
An array runs each entry as its own command, sequentially, equivalent to joining them with `&&`. It is **not** a way to split one command into argv tokens — `['vp', 'build']` would try to run a command called `vp` with no arguments, then a command called `build`, instead of `vp build`.
86103

87104
```ts [vite.config.ts]
88105
tasks: {
89-
build: 'vp build',
90-
check: ['vp lint', 'vp build'],
106+
check: {
107+
// Two commands, run in order
108+
command: ['vp lint', 'vp build'],
109+
},
110+
bad: {
111+
// Wrong: this is NOT `vp build`; it is `vp` followed by `build`
112+
command: ['vp', 'build'],
113+
},
91114
}
92115
```
93116

0 commit comments

Comments
 (0)