We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The documentation about hook execution says:
pre_prompt: Scripts run in the root directory of a copy of the repository directory. That allows the rewrite of cookiecutter.json to your own needs.
However, it is not clear how to rewrite cookiecutter.json as the provided example does something else.
cookiecutter.json
I'd love an example showing how pre_prompt could be used to inject a variable into the cookiecutter.json.
pre_prompt
The text was updated successfully, but these errors were encountered:
I'd like to see this too (did you find an example of this anywhere online @andredias?)
Sorry, something went wrong.
I created an example to insert the current Python version into the cookiecutter.json file:
# hooks/pre_prompt.py import json import sys from pathlib import Path config = Path("cookiecutter.json") data = json.loads(config.read_text()) data["python_version"] = f"{sys.version_info.major}.{sys.version_info.minor}" config.write_text(json.dumps(data, indent=4))
Thanks for the example @andredias, that worked for me.
I have a working example of this here now, in case it's helpful for others.
No branches or pull requests
Description:
The documentation about hook execution says:
However, it is not clear how to rewrite
cookiecutter.json
as the provided example does something else.I'd love an example showing how
pre_prompt
could be used to inject a variable into thecookiecutter.json
.The text was updated successfully, but these errors were encountered: