feat: added recursively copying static files
This commit is contained in:
parent
8e64e48097
commit
b28bb33412
@ -9,10 +9,7 @@ from .config import SOURCE_DIRECTORY, DIST_DIRECTORY, STATIC_DIRECTORY
|
||||
logger = logging.getLogger("stsg.build")
|
||||
|
||||
|
||||
def copy_static():
|
||||
src = str(Path(SOURCE_DIRECTORY, STATIC_DIRECTORY))
|
||||
dst = str(Path(DIST_DIRECTORY, STATIC_DIRECTORY))
|
||||
|
||||
def copy_static(src, dst):
|
||||
if not os.path.exists(src):
|
||||
logger.warn("The static folder '%s' wasn't defined.", src)
|
||||
return
|
||||
@ -67,9 +64,30 @@ class Context:
|
||||
return text
|
||||
|
||||
|
||||
def walk_directory(root):
|
||||
src_path = Path(SOURCE_DIRECTORY, root)
|
||||
dst_path = Path(DIST_DIRECTORY, root)
|
||||
|
||||
for current_full_path in src_path.iterdir():
|
||||
current_name = Path(current_full_path).name
|
||||
current_dst = Path(dst_path, current_name)
|
||||
current_src = Path(src_path, current_name)
|
||||
|
||||
if current_name == "static":
|
||||
print(current_src, current_dst)
|
||||
copy_static(current_src, current_dst)
|
||||
continue
|
||||
|
||||
if current_dst.is_dir():
|
||||
walk_directory(Path(root, current_full_path.name))
|
||||
|
||||
|
||||
def build():
|
||||
logger.info("building static page")
|
||||
copy_static()
|
||||
|
||||
walk_directory("")
|
||||
return
|
||||
# copy_static()
|
||||
|
||||
context = Context()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user