Merge branch 'feature/bonobo-init-should-work-on-an-empty-existing-directory' of git://github.com/arimbr/bonobo into arimbr-feature/bonobo-init-should-work-on-an-empty-existing-directory

This commit is contained in:
Romain Dorgueil
2017-10-23 22:45:39 +02:00
2 changed files with 45 additions and 1 deletions

View File

@ -1,3 +1,5 @@
import os
def execute(name, branch):
try:
from cookiecutter.main import cookiecutter
@ -6,11 +8,17 @@ def execute(name, branch):
'You must install "cookiecutter" to use this command.\n\n $ pip install cookiecutter\n'
) from exc
overwrite_if_exists = False
project_path = os.path.join(os.getcwd(), name)
if os.path.isdir(project_path) and not os.listdir(project_path):
overwrite_if_exists = True
return cookiecutter(
'https://github.com/python-bonobo/cookiecutter-bonobo.git',
extra_context={'name': name},
no_input=True,
checkout=branch
checkout=branch,
overwrite_if_exists=overwrite_if_exists
)