new ensure_dir logic
+ better logs + docker files + new docs
This commit is contained in:
@ -19,10 +19,25 @@ def load_theme_config(theme_name, themes_dir):
|
||||
theme_vars = yaml.safe_load(f)
|
||||
return theme_vars, theme_dir
|
||||
|
||||
def ensure_dir(path):
|
||||
if path.exists():
|
||||
rmtree(path)
|
||||
path.mkdir(parents=True)
|
||||
def clear_dir(path: Path):
|
||||
if not path.exists():
|
||||
path.mkdir(parents=True)
|
||||
return
|
||||
|
||||
# Remove all files and subdirectories inside path, but not path itself
|
||||
for child in path.iterdir():
|
||||
if child.is_file() or child.is_symlink():
|
||||
child.unlink() # delete file or symlink
|
||||
elif child.is_dir():
|
||||
rmtree(child) # delete directory and contents
|
||||
|
||||
# Then replace your ensure_dir with this:
|
||||
|
||||
def ensure_dir(path: Path):
|
||||
if not path.exists():
|
||||
path.mkdir(parents=True)
|
||||
else:
|
||||
clear_dir(path)
|
||||
|
||||
def copy_assets(js_dir, style_dir, build_dir):
|
||||
for folder in [js_dir, style_dir]:
|
||||
|
Reference in New Issue
Block a user