Skip to content

Commit 34859f9

Browse files
committed
docs: complete staged command guide
1 parent 31960c0 commit 34859f9

2 files changed

Lines changed: 188 additions & 4 deletions

File tree

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,99 @@
11
# staged
22

3-
TODO.
3+
The `rs staged` command uses [lint-staged](https://github.com/lint-staged/lint-staged) to run tasks against files staged in Git.
4+
5+
A common use case is to run linters, formatters, or other checks on staged files before committing code.
6+
7+
## Usage
8+
9+
```bash
10+
rs staged [options]
11+
```
12+
13+
The command loads the staged-file tasks registered with [`define.staged()`](../configuration#define-staged).
14+
15+
## Options
16+
17+
### `--allow-empty`
18+
19+
`--allow-empty` allows an empty commit when tasks revert all staged changes.
20+
21+
```bash
22+
rs staged --allow-empty
23+
```
24+
25+
### `--concurrent`
26+
27+
`--concurrent` (or `-p`) sets how many tasks run concurrently; use `false` to run them serially.
28+
29+
```bash
30+
rs staged --concurrent false
31+
```
32+
33+
### `--cwd`
34+
35+
`--cwd` sets the working directory used to run all tasks.
36+
37+
```bash
38+
rs staged --cwd packages/app
39+
```
40+
41+
### `--debug`
42+
43+
`--debug` (or `-d`) prints additional debug information.
44+
45+
```bash
46+
rs staged --debug
47+
```
48+
49+
### `--no-stash`
50+
51+
`--no-stash` disables the backup stash and keeps changes made by tasks when an error occurs.
52+
53+
```bash
54+
rs staged --no-stash
55+
```
56+
57+
### `--quiet`
58+
59+
`--quiet` (or `-q`) disables lint-staged's own console output.
60+
61+
```bash
62+
rs staged --quiet
63+
```
64+
65+
### `--relative`
66+
67+
`--relative` (or `-r`) passes file paths relative to the working directory to tasks.
68+
69+
```bash
70+
rs staged --relative
71+
```
72+
73+
### `--verbose`
74+
75+
`--verbose` (or `-v`) shows task output even when tasks succeed; by default, only output from failed tasks is displayed.
76+
77+
```bash
78+
rs staged --verbose
79+
```
80+
81+
### `--help`
82+
83+
`--help` (or `-h`) displays the command's usage and options.
84+
85+
```bash
86+
rs staged --help
87+
```
488

589
## Configuration
690

7-
See [`define.staged()`](../configuration#define-staged).
91+
Configure staged-file tasks through [`define.staged()`](../configuration#define-staged) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [lint-staged configuration](https://github.com/lint-staged/lint-staged#configuration):
92+
93+
```ts title="rstack.config.ts"
94+
import { define } from 'rstack';
95+
96+
define.staged({
97+
'*.{js,jsx,ts,tsx}': 'rs lint',
98+
});
99+
```
Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,99 @@
11
# staged
22

3-
TODO.
3+
`rs staged` 命令使用 [lint-staged](https://github.com/lint-staged/lint-staged) 对 Git 暂存文件运行任务。
4+
5+
常见的使用场景是在提交代码前,对暂存文件运行 linter、格式化工具或其他检查。
6+
7+
## 用法 \{#usage}
8+
9+
```bash
10+
rs staged [options]
11+
```
12+
13+
该命令会加载通过 [`define.staged()`](../configuration#define-staged) 注册的暂存文件任务。
14+
15+
## 选项 \{#options}
16+
17+
### `--allow-empty`
18+
19+
`--allow-empty` 允许在任务撤销全部暂存变更时创建空提交。
20+
21+
```bash
22+
rs staged --allow-empty
23+
```
24+
25+
### `--concurrent`
26+
27+
`--concurrent`(或 `-p`)用于设置并发运行的任务数量;设为 `false` 时串行运行。
28+
29+
```bash
30+
rs staged --concurrent false
31+
```
32+
33+
### `--cwd`
34+
35+
`--cwd` 用于设置运行所有任务时使用的工作目录。
36+
37+
```bash
38+
rs staged --cwd packages/app
39+
```
40+
41+
### `--debug`
42+
43+
`--debug`(或 `-d`)用于输出额外的调试信息。
44+
45+
```bash
46+
rs staged --debug
47+
```
48+
49+
### `--no-stash`
50+
51+
`--no-stash` 会禁用备份 stash,并在出错时保留任务产生的变更。
52+
53+
```bash
54+
rs staged --no-stash
55+
```
56+
57+
### `--quiet`
58+
59+
`--quiet`(或 `-q`)用于禁用 lint-staged 自身的控制台输出。
60+
61+
```bash
62+
rs staged --quiet
63+
```
64+
65+
### `--relative`
66+
67+
`--relative`(或 `-r`)会将相对于工作目录的文件路径传递给任务。
68+
69+
```bash
70+
rs staged --relative
71+
```
72+
73+
### `--verbose`
74+
75+
`--verbose`(或 `-v`)会在任务成功时也显示其输出;默认仅显示失败任务的输出。
76+
77+
```bash
78+
rs staged --verbose
79+
```
80+
81+
### `--help`
82+
83+
`--help`(或 `-h`)用于显示命令的用法和选项。
84+
85+
```bash
86+
rs staged --help
87+
```
488

589
## 配置 \{#configuration}
690

7-
参见 [`define.staged()`](../configuration#define-staged)
91+
[Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.staged()`](../configuration#define-staged) 配置暂存文件任务。该 API 支持标准的 [lint-staged 配置](https://github.com/lint-staged/lint-staged#configuration)
92+
93+
```ts title="rstack.config.ts"
94+
import { define } from 'rstack';
95+
96+
define.staged({
97+
'*.{js,jsx,ts,tsx}': 'rs lint',
98+
});
99+
```

0 commit comments

Comments
 (0)