Skip to content

Commit

Permalink
Added checks for runserver_plus management command to give a nice e…
Browse files Browse the repository at this point in the history
…rror messages, when `django-extensions` and `Werkzeug` are not properly installed.
  • Loading branch information
oliverandrich committed Oct 4, 2023
1 parent 69e70b5 commit ec0a4ef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.4.1 (Unreleased)

- Added checks for `runserver_plus` management command to give a nice error messages, when `django-extensions` and `Werkzeug` are not properly installed.

## 2.4.0

- Back to Poetry for project management.
Expand Down
14 changes: 11 additions & 3 deletions src/django_tailwind_cli/management/commands/tailwind.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""`tailwind` management command."""

import importlib.util
import os
import shutil
import ssl
Expand Down Expand Up @@ -52,7 +53,7 @@ def add_arguments(self, parser: Any) -> None:

runserver_plus_parser = subparsers.add_parser(
"runserver_plus",
help="Start the Django Extensions runserver_plus development server and the Tailwind CLI in watch mode.",
help="Start the django-extensions runserver_plus development server and the Tailwind CLI in watch mode.",
)

runserver_plus_parser.add_argument("addrport", nargs="?", help="Optional port number, or ipaddr:port")
Expand Down Expand Up @@ -88,9 +89,16 @@ def handle(self, *_args: Any, **kwargs: Any) -> None:
self.build()
elif label == "watch":
self.watch()
elif label in ("runserver", "runserver_plus"): # pragma: no cover
kwargs["runserver_cmd"] = label
elif label == "runserver": # pragma: no cover
kwargs["runserver_cmd"] = "runserver"
self.runserver(**kwargs)
elif label == "runserver_plus": # pragma: no cover
if importlib.util.find_spec("django_extensions") and importlib.util.find_spec("werkzeug"):
kwargs["runserver_cmd"] = "runserver"
self.runserver(**kwargs)
else:
msg = "Missing dependencies. Follow the instructions found on https://django-tailwind-cli.andrich.me/installation/."
raise CommandError(msg)
elif label == "list_templates":
self.list_templates()

Expand Down

0 comments on commit ec0a4ef

Please sign in to comment.