🪝 Pre and Post Hooks
Hooks let you run custom scripts before or after project generation.
What are Hooks?
- Pre-hook: Executes before template generation.
- Post-hook: Executes after template generation.
Hook Files Location
- Hooks are stored as shell scripts inside the project template folder:
.quick-start/hooks/pre\_hook.sh
.quick-start/hooks/post\_hook.sh
````
---
## Adding Hooks
1. Create `pre_hook.sh` and/or `post_hook.sh` scripts in `.quick-start/hooks/`.
2. Write your custom commands in these scripts.
3. When generating a project:
- The **pre-hook** runs first.
- Then the template is generated.
- Then the **post-hook** runs.
---
## Example Pre Hook (`pre_hook.sh`)
```bash
#!/bin/bash
echo "Running pre-generation tasks..."
# e.g., check dependencies
node -v || echo "Warning: Node.js not found"
````
---
## Example Post Hook (`post_hook.sh`)
```bash
#!/bin/bash
echo "Running post-generation tasks..."
# e.g., install dependencies
npm install
Notes
- Make sure hooks are executable (
chmod +x pre_hook.sh post_hook.sh
). - Errors in hooks may stop or warn during generation.
- Hooks allow automation around your project scaffolding process.
➡️ Next: Excluding Files and Folders