Hooks
What are hooks?
Section titled “What are hooks?”Hooks are shell commands that run after project generation. Configure them in diecut.toml.
[hooks]post_create = "git init"The command runs in the generated project directory via sh -c.
Examples
Section titled “Examples”Initialize a git repo with initial commit
Section titled “Initialize a git repo with initial commit”[hooks]post_create = "git init && git add -A && git commit -m 'Initial commit'"Install dependencies
Section titled “Install dependencies”Python project:
[hooks]post_create = "pip install -e ."Node.js project:
[hooks]post_create = "npm install"Rust project:
[hooks]post_create = "cargo build"Run a setup script
Section titled “Run a setup script”[hooks]post_create = "./setup.sh"The script must be in the template’s template/ directory and will be copied to the output before the hook runs.
Security
Section titled “Security”When generating from a remote template that contains hooks, diecut prints a warning:
warning: This template contains hooks that will execute code on your machine source: https://github.com/user/repo.git use --no-hooks to skip hook executionUse --no-hooks to skip hook execution for untrusted templates.