Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I stop the cookiecutter if my hook fails?

I'm using cookiecutter to help manage a web template. You can specify a special file hooks/pre_gen_project.py that will run before any of the template commands start. If it fails however, cookiecutter keeps going, even if hooks/pre_gen_project.py throws an exception! A minimal example would simply be:

raise SyntaxError

in this file. Is there a way to halt execution once an error has been raised?

like image 654
Hooked Avatar asked Dec 15 '25 02:12

Hooked


1 Answers

Until recently, cookiecutter ignored errors in the hook scripts. I've submited a fix for this that got merged recently.

So, if you use Cookiecutter >= 1.3.0, the project generation will be canceled when the hook script fails. :)

like image 60
Elias Dorneles Avatar answered Dec 16 '25 19:12

Elias Dorneles



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!