Skip to content

Commit 17bf9cf

Browse files
⚙️ FEATURE: Add conditional removal of test_auth.py and github workflow in hooks
1 parent 6daf599 commit 17bf9cf

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

hooks/post_gen_project.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,34 @@ def remove_templates() -> None:
3333
rmtree(context_path)
3434

3535

36+
def remove_github_workflow() -> None:
37+
workflow_path = CONTEXT.joinpath('.github', 'workflows', 'python-app-code.yml')
38+
if workflow_path.exists():
39+
remove(workflow_path)
40+
41+
github_dir = CONTEXT.joinpath('.github', 'workflows')
42+
if github_dir.exists() and not any(github_dir.iterdir()):
43+
rmtree(CONTEXT.joinpath('.github'))
44+
45+
46+
def remove_test_auth() -> None:
47+
test_auth_path = CONTEXT.joinpath('tests', 'test_auth.py')
48+
if test_auth_path.exists():
49+
remove(test_auth_path)
50+
51+
3652
def main():
3753
if "{{ cookiecutter.use_mkdocs }}" != "y":
3854
remove_mkdocs()
3955

4056
if "{{ cookiecutter.use_templates }}" != "y":
4157
remove_templates()
4258

43-
if "{{ cookiecutter.use_auth }}" == "y":
44-
remove_endpoint(file='item.py')
45-
rename_endpoint(file='item_auth.py', for_file='item.py')
46-
else:
47-
remove_endpoint(file='item_auth.py')
59+
if "{{ cookiecutter.github_action_code_scan }}" != "y":
60+
remove_github_workflow()
61+
62+
if "{{ cookiecutter.use_auth }}" == "n":
63+
remove_test_auth()
4864

4965

5066
if __name__ == "__main__":

0 commit comments

Comments
 (0)