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