Skip to content

Commit fdf5c1e

Browse files
authored
docs: fix hooks documentation to reflect actual implementation (#18)
The documentation incorrectly showed a separate 'hooks' section that is not implemented in the codebase. The actual implementation only supports inline hooks within command configurations using 'pre' and 'post' properties. Changes: - Remove misleading 'hooks' section examples from configuration.md and commands.md - Replace with correct documentation showing inline hooks within commands - Update examples to show the actual supported syntax This addresses the discrepancy between documented and actual functionality. A separate issue will be created to track implementing the external hooks section as a future enhancement.
1 parent 567fd5a commit fdf5c1e

File tree

2 files changed

+40
-50
lines changed

2 files changed

+40
-50
lines changed

website/content/commands.md

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -203,40 +203,36 @@ Set environment variables for commands:
203203

204204
## Command Hooks
205205

206-
Run commands before or after built-in mvx commands:
206+
Add pre and post hooks to built-in mvx commands by defining them within the command configuration:
207207

208208
```json5
209209
{
210-
hooks: {
211-
"pre-setup": {
212-
description: "Prepare environment before setup",
213-
script: "echo 'Preparing environment...'"
214-
},
215-
"post-setup": {
216-
description: "Verify installation after setup",
217-
script: [
210+
commands: {
211+
// Add hooks to built-in 'setup' command
212+
setup: {
213+
description: "Setup with custom hooks",
214+
pre: "echo 'Preparing environment...'",
215+
post: [
218216
"echo 'Verifying tools...'",
219217
"./mvx tools verify java",
220218
"./mvx tools verify maven"
221219
]
222220
},
223-
"pre-build": {
224-
description: "Pre-build checks",
225-
script: "echo 'Running pre-build checks...'"
226-
},
227-
"post-build": {
228-
description: "Post-build actions",
229-
script: "echo 'Build completed successfully!'"
221+
222+
// Add hooks to built-in 'build' command
223+
build: {
224+
description: "Build with pre-checks",
225+
pre: "echo 'Running pre-build checks...'",
226+
post: "echo 'Build completed successfully!'"
230227
}
231228
}
232229
}
233230
```
234231

235-
Available hook points:
236-
- `pre-setup` / `post-setup`
237-
- `pre-build` / `post-build` (for custom build commands)
238-
- `pre-test` / `post-test` (for custom test commands)
239-
- `pre-clean` / `post-clean`
232+
Hook properties:
233+
- `pre` - Script to run before the built-in command
234+
- `post` - Script to run after the built-in command
235+
- Both support single strings or arrays of commands
240236

241237
## Command Overrides
242238

website/content/configuration.md

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,7 @@ mvx uses a JSON5 configuration file (`.mvx/config.json5`) to define your project
3838
}
3939
},
4040

41-
// Command hooks (optional)
42-
hooks: {
43-
"pre-build": {
44-
description: "Run before build",
45-
script: "echo 'Starting build...'"
46-
},
47-
"post-build": {
48-
description: "Run after build",
49-
script: "echo 'Build completed!'"
50-
}
51-
}
41+
5242
}
5343
```
5444

@@ -189,34 +179,38 @@ Define custom commands that become available as `./mvx <command>`:
189179
}
190180
```
191181

192-
## Hooks Section
182+
## Command Hooks
193183

194-
Hooks allow you to run commands before or after built-in mvx commands:
184+
You can add pre and post hooks to built-in mvx commands by defining them within the command configuration:
195185

196186
```json5
197187
{
198-
hooks: {
199-
"pre-setup": {
200-
description: "Prepare environment",
201-
script: "echo 'Preparing environment...'"
202-
},
203-
"post-setup": {
204-
description: "Verify installation",
205-
script: "echo 'Verifying tools...'"
188+
commands: {
189+
// Add hooks to the built-in 'build' command
190+
build: {
191+
description: "Build with custom hooks",
192+
pre: "echo 'Starting build...'",
193+
post: "echo 'Build completed!'"
206194
},
207-
"pre-build": {
208-
description: "Pre-build checks",
209-
script: "echo 'Running pre-build checks...'"
195+
196+
// Add hooks to the built-in 'test' command
197+
test: {
198+
description: "Test with verification",
199+
pre: "echo 'Preparing test environment...'",
200+
post: [
201+
"echo 'Tests completed!'",
202+
"echo 'Generating reports...'"
203+
]
210204
}
211205
}
212206
}
213207
```
214208

215-
Available hook points:
216-
- `pre-setup` / `post-setup`
217-
- `pre-build` / `post-build`
218-
- `pre-test` / `post-test`
219-
- `pre-clean` / `post-clean`
209+
Available hook points for built-in commands:
210+
- `build` - Build command hooks
211+
- `test` - Test command hooks
212+
- `setup` - Setup command hooks
213+
- `clean` - Clean command hooks
220214

221215
## Command Overrides
222216

0 commit comments

Comments
 (0)