From df45251622e6b935b27022e36fcbd79e9228f989 Mon Sep 17 00:00:00 2001 From: arimbr Date: Sun, 22 Oct 2017 23:05:58 +0200 Subject: [PATCH] Check if target directory is empty instead of current directory and remove overwrite_if_exists argument --- bonobo/commands/init.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bonobo/commands/init.py b/bonobo/commands/init.py index 9a157ca..e69156c 100644 --- a/bonobo/commands/init.py +++ b/bonobo/commands/init.py @@ -1,6 +1,6 @@ import os -def execute(name, branch, overwrite_if_exists=False): +def execute(name, branch): try: from cookiecutter.main import cookiecutter except ImportError as exc: @@ -8,7 +8,9 @@ def execute(name, branch, overwrite_if_exists=False): 'You must install "cookiecutter" to use this command.\n\n $ pip install cookiecutter\n' ) from exc - if os.listdir(os.getcwd()) == []: + 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(