Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecation warning for distutils module in craft auth command #563

Merged
merged 2 commits into from
Mar 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions src/masonite/commands/AuthCommand.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Scaffold Auth Command."""
from distutils.dir_util import copy_tree
from shutil import copytree
import os
import sys

from ..utils.location import controllers_path, views_path, mailables_path
from ..utils.filesystem import get_module_dir
Expand All @@ -19,13 +20,21 @@ def __init__(self, application):
self.app = application

def handle(self):
copy_tree(
self.get_template_path(),
views_path("auth"),
)
copy_tree(self.get_controllers_path(), controllers_path("auth"))

copy_tree(self.mailables_path(), mailables_path())
# dirs_exist_ok option is available in Python 3.8+
# https://docs.python.org/3/library/shutil.html#shutil.copytree
if sys.version_info.minor >= 8:
copytree(self.get_template_path(), views_path("auth"), dirs_exist_ok=True)
copytree(
self.get_controllers_path(),
controllers_path("auth"),
dirs_exist_ok=True,
)

copytree(self.mailables_path(), mailables_path(), dirs_exist_ok=True)
else:
copytree(self.get_template_path(), views_path("auth"))
copytree(self.get_controllers_path(), controllers_path("auth"))
copytree(self.mailables_path(), mailables_path())

self.info("Auth scaffolded successfully!")

Expand Down