Merge pull request #108 from lqmanh/features/make-parent-dirs-as-needed
Make parent directories as needed
This commit is contained in:
commit
78a15f9f19
@ -240,8 +240,7 @@ async def init(
|
||||
with open(config_file, "w", encoding="utf-8") as f:
|
||||
parser.write(f)
|
||||
|
||||
if not Path(location).is_dir():
|
||||
os.mkdir(location)
|
||||
Path(location).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
click.secho(f"Success create migrate location {location}", fg=Color.green)
|
||||
click.secho(f"Success generate config file {config_file}", fg=Color.green)
|
||||
@ -263,10 +262,10 @@ async def init_db(ctx: Context, safe):
|
||||
app = ctx.obj["app"]
|
||||
|
||||
dirname = Path(location, app)
|
||||
if not dirname.is_dir():
|
||||
os.mkdir(dirname)
|
||||
try:
|
||||
dirname.mkdir(parents=True)
|
||||
click.secho(f"Success create app migrate location {dirname}", fg=Color.green)
|
||||
else:
|
||||
except FileExistsError:
|
||||
return click.secho(
|
||||
f"Inited {app} already, or delete {dirname} and try again.", fg=Color.yellow
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user