Skip to content

Commit

Permalink
fix get_usage_script #156
Browse files Browse the repository at this point in the history
  • Loading branch information
bckohan committed Jan 2, 2025
1 parent 67bc455 commit ba86354
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion django_typer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def get_usage_script(script: t.Optional[str] = None) -> t.Union[Path, str]:
:return: The script name or the relative path to the script from cwd.
"""
cmd_pth = Path(script or sys.argv[0])
if shutil.which(cmd_pth.name):
on_path = shutil.which(cmd_pth.name)
if on_path and Path(on_path).is_absolute():
return cmd_pth.name
try:
return cmd_pth.absolute().relative_to(Path(os.getcwd()))
Expand Down

0 comments on commit ba86354

Please sign in to comment.