File tree Expand file tree Collapse file tree 2 files changed +92
-4
lines changed Expand file tree Collapse file tree 2 files changed +92
-4
lines changed Original file line number Diff line number Diff line change @@ -147,10 +147,30 @@ Info about git hooks can be found on [Git documentation](https://git-scm.com/boo
147
147
148
148
For a first simple usage test of commitlint you can do the following:
149
149
150
- ` ` ` bash
150
+ ::: code-group
151
+
152
+ ` ` ` sh [npm]
151
153
npx commitlint --from HEAD~1 --to HEAD --verbose
152
154
` ` `
153
155
156
+ ` ` ` sh [yarn]
157
+ yarn commitlint --from HEAD~1 --to HEAD --verbose
158
+ ` ` `
159
+
160
+ ` ` ` sh [pnpm]
161
+ pnpm dlx commitlint --from HEAD~1 --to HEAD --verbose
162
+ ` ` `
163
+
164
+ ` ` ` sh [bun]
165
+ bunx commitlint --from HEAD~1 --to HEAD --verbose
166
+ ` ` `
167
+
168
+ ` ` ` sh [deno]
169
+ deno task --eval commitlint --from HEAD~1 --to HEAD --verbose
170
+ ` ` `
171
+
172
+ :::
173
+
154
174
This will check your last commit and return an error if invalid or a positive output if valid.
155
175
156
176
# ## Test the hook
Original file line number Diff line number Diff line change 12
12
13
13
2 . Create a package.json if needed
14
14
15
- ``` sh
15
+ ::: code-group
16
+
17
+ ``` sh [npm]
16
18
npm init
17
19
```
18
20
21
+ ``` sh [yarn]
22
+ yarn init
23
+ ```
24
+
25
+ ``` sh [pnpm]
26
+ pnpm init
27
+ ```
28
+
29
+ ``` sh [bun]
30
+ bun init
31
+ ```
32
+
33
+ :::
34
+
19
35
3 . Install and configure if needed
20
36
21
- ``` sh
37
+ ::: code-group
38
+
39
+ ``` sh [npm]
22
40
npm install --save-dev @commitlint/cli @commitlint/config-conventional @commitlint/prompt-cli
23
41
24
42
echo " export default { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
25
43
```
26
44
45
+ ``` sh [yarn]
46
+ yarn add --dev @commitlint/cli @commitlint/config-conventional @commitlint/prompt-cli
47
+
48
+ echo " export default { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
49
+ ```
50
+
51
+ ``` sh [pnpm]
52
+ pnpm add --save-dev @commitlint/cli @commitlint/config-conventional @commitlint/prompt-cli
53
+
54
+ echo " export default { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
55
+ ```
56
+
57
+ ``` sh [bun]
58
+ bun add --dev @commitlint/cli @commitlint/config-conventional @commitlint/prompt-cli
59
+
60
+ echo " export default { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
61
+ ```
62
+
63
+ ``` sh [deno]
64
+ deno add --dev npm:@commitlint/cli npm:@commitlint/config-conventional npm:@commitlint/prompt-cli
65
+
66
+ echo " export default { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
67
+ ```
68
+
69
+ :::
70
+
27
71
## Provide a shortcut
28
72
29
73
To make prompt-cli easy to use, add a npm run-script to your ` package.json `
@@ -38,11 +82,35 @@ To make prompt-cli easy to use, add a npm run-script to your `package.json`
38
82
39
83
Test the prompt by executing
40
84
41
- ``` bash
85
+ ::: code-group
86
+
87
+ ``` sh [npm]
42
88
git add .
43
89
npm run commit
44
90
```
45
91
92
+ ``` sh [yarn]
93
+ git add .
94
+ yarn commit
95
+ ```
96
+
97
+ ``` sh [pnpm]
98
+ git add .
99
+ pnpm commit
100
+ ```
101
+
102
+ ``` sh [bun]
103
+ git add .
104
+ bun commit
105
+ ```
106
+
107
+ ``` sh [deno]
108
+ git add .
109
+ deno task commit
110
+ ```
111
+
112
+ :::
113
+
46
114
## An alternative to ` @commitlint/prompt-cli ` : commitizen
47
115
48
116
Another way to author commit messages that adhere to the commit convention configured in ` commitlint.config.js ` is to use ` commitizen ` .
You can’t perform that action at this time.
0 commit comments