Skip to content

Commit a25e540

Browse files
committed
fix path judgment
1 parent 3e67c44 commit a25e540

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

fastapi_ccli/cloner/cloner_en.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
3+
import os
34
import re
45
import time
6+
from pathlib import Path
57
from typing import Optional
68

79
import typer
@@ -61,10 +63,9 @@ def exec_clone(orm: str, country: str, project: str, path: str) -> None:
6163
source = github_fsm_src
6264
try:
6365
print(f"⏳ Start clone {source.split('/')[-1].split('.')[0]} project...") # noqa
64-
# out = os.system(f"git clone {source} {path}")
65-
# if out != 0:
66-
# raise RuntimeError(out)
67-
print(orm, country, project, path)
66+
out = os.system(f"git clone {source} {path}")
67+
if out != 0:
68+
raise RuntimeError(out)
6869
except Exception as e:
6970
print(f"❌ Clone project failed: {e}")
7071
raise typer.Exit(1)
@@ -106,7 +107,7 @@ def cloner(
106107
if orm not in ["sqlalchemy", "tortoise", "sqlmodel"]:
107108
raise typer.BadParameter("Enter unknown parameters, only allowed 'sqlalchemy' / 'tortoise' / 'sqlmodel'")
108109
if project_path:
109-
if not isinstance(project_path, str):
110+
if not Path(project_path).is_dir():
110111
raise typer.BadParameter("Wrong parameter input, please enter the correct path")
111112
use_project_name = project_path or "../fastapi_project"
112113
path = get_project_path(use_project_name)

fastapi_ccli/cloner/cloner_en_form.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33
import re
4+
from pathlib import Path
45
from typing import Optional
56

67
import questionary
@@ -36,7 +37,7 @@ def cloner(
3637
if version:
3738
typer.secho("\n🔥 FastAPI CCLI " + __version__, fg="green", bold=True)
3839
if project_path:
39-
if not isinstance(project_path, str):
40+
if not Path(project_path).is_dir():
4041
raise typer.BadParameter("Wrong parameter input, please enter the correct path")
4142
use_project_name = project_path or "../fastapi_project"
4243
path = get_project_path(use_project_name)

0 commit comments

Comments
 (0)