From 4f3ec4ddca74e056c775227fdeb94a800786ae04 Mon Sep 17 00:00:00 2001 From: "Nikita P. Shupeyko" Date: Thu, 24 Aug 2017 17:44:23 +0300 Subject: [PATCH] Post-gen gitignore .env/ and .env --- hooks/post_gen_project.py | 17 +++++++++++++++++ {{cookiecutter.project_slug}}/.gitignore | 2 -- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index b383e4190..678848e92 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -202,6 +202,15 @@ def remove_open_source_files(): PROJECT_DIRECTORY, filename )) +def append_to_gitignore(path): + """ + Append path to `.gitignore`. + + :param path: File/dir path to append. + """ + gitignore_file_path = os.path.join(PROJECT_DIRECTORY, '.gitignore') + with open(gitignore_file_path, 'a') as gitignore_file: + gitignore_file.write(path) # IN PROGRESS # def copy_doc_files(project_directory): @@ -271,3 +280,11 @@ if '{{ cookiecutter.use_elasticbeanstalk_experimental }}'.lower() != 'y': # Remove files conventional to opensource projects only. if '{{ cookiecutter.open_source_license }}' == 'Not open source': remove_open_source_files() + +# Append `.env/` to the generated project's `.gitignore`. +dotenv_dir_path = '.env/' +append_to_gitignore(dotenv_dir_path) + +# Append `.env` to the generated project's `.gitignore`. +dotenv_dir_path = '.env' +append_to_gitignore(dotenv_dir_path) diff --git a/{{cookiecutter.project_slug}}/.gitignore b/{{cookiecutter.project_slug}}/.gitignore index 6fd1c92e5..4ef36b789 100644 --- a/{{cookiecutter.project_slug}}/.gitignore +++ b/{{cookiecutter.project_slug}}/.gitignore @@ -66,9 +66,7 @@ target/ celerybeat-schedule # Environments -.env .venv -env/ venv/ ENV/