From 5e2ab6e07a62952cb188bb25212817880ce9e3ff Mon Sep 17 00:00:00 2001 From: Victor Mattos <5757883+vicmattos@users.noreply.github.com> Date: Tue, 21 Nov 2023 00:44:47 -0300 Subject: [PATCH] refactor(template): simplify folder remove in `post_gen_project.py` by using `shutil.rmtree` --- cookiecutter/tap-template/hooks/post_gen_project.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/cookiecutter/tap-template/hooks/post_gen_project.py b/cookiecutter/tap-template/hooks/post_gen_project.py index 62cd5425c..dee46e615 100644 --- a/cookiecutter/tap-template/hooks/post_gen_project.py +++ b/cookiecutter/tap-template/hooks/post_gen_project.py @@ -1,19 +1,11 @@ #!/usr/bin/env python from pathlib import Path +import shutil BASE_PATH = Path('{{cookiecutter.library_name}}') -def delete_folder(pth: Path): - for sub in pth.iterdir(): - if sub.is_dir(): - delete_folder(sub) - else: - sub.unlink() - pth.rmdir() - - if __name__ == '__main__': # Rename stream type client and delete others @@ -31,5 +23,5 @@ def delete_folder(pth: Path): Path('LICENSE').unlink() if '{{ cookiecutter.include_ci_files }}' != 'GitHub': - delete_folder(Path('.github')) + shutil.rmtree(Path('.github'))