From 4d0b1e1c86bb46d11b2fddd95a1cc47e9e8e2304 Mon Sep 17 00:00:00 2001 From: Pavel Kirilin <win10@list.ru> Date: Thu, 2 May 2024 04:10:29 +0200 Subject: [PATCH] Cleaned up build script. Signed-off-by: Pavel Kirilin <win10@list.ru> --- build.py | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/build.py b/build.py index 7273c4c..c86879d 100644 --- a/build.py +++ b/build.py @@ -1,4 +1,3 @@ -import os from pathlib import Path import shutil import subprocess @@ -10,20 +9,7 @@ FRONTEND_DIR = CURRENT_DIR / "frontend" DIST_DIR = FRONTEND_DIR / "dist" -class DirChanger: - """Class for changing current directory and returning back after exit.""" - - def __init__(self, path: Path): - self.path = path - - def __enter__(self): - os.chdir(self.path) - - def __exit__(self, *args): - os.chdir(CURRENT_DIR) - - -def build(setup_kwargs): +def build(): """ Build frontend and copy it to the static directory. @@ -33,19 +19,12 @@ def build(setup_kwargs): pnpm_path = shutil.which("pnpm") if pnpm_path is None: raise Exception("pnpm command is not available. PLease install pnpm.") - - subprocess.run( - [pnpm_path, "build"], - cwd=CURRENT_DIR / "frontend", - check=True, - ) - + subprocess.run([pnpm_path, "build"], cwd=FRONTEND_DIR, check=True) print("Frontend build finished.") + print("Copying static files ...") shutil.rmtree(STATIC_OUTPUT_DIR, ignore_errors=True) shutil.copytree(symlinks=True, src=DIST_DIR, dst=STATIC_OUTPUT_DIR) - return setup_kwargs - if __name__ == "__main__": - build({}) + build() -- GitLab