From c98131f76bb55cd0adb25fb2ae964ac299b635ca Mon Sep 17 00:00:00 2001 From: Ivan Date: Mon, 1 Dec 2025 11:06:10 -0600 Subject: [PATCH] refactor: frontend preparation script with error handling - Added a check to ensure the script is run from the project root by verifying the existence of pyproject.toml. - Implemented a safeguard against removing the TARGET directory if it is a symlink, raising an appropriate error message. --- scripts/prepare_frontend_dir.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/prepare_frontend_dir.py b/scripts/prepare_frontend_dir.py index a88c1bc..881c5e1 100644 --- a/scripts/prepare_frontend_dir.py +++ b/scripts/prepare_frontend_dir.py @@ -1,10 +1,14 @@ -#!/usr/bin/env python3 from pathlib import Path import shutil TARGET = Path("meshchatx") / "public" +if not Path("pyproject.toml").exists(): + raise RuntimeError("Must run from project root") + if TARGET.exists(): + if TARGET.is_symlink(): + raise RuntimeError(f"{TARGET} is a symlink, refusing to remove") shutil.rmtree(TARGET) TARGET.mkdir(parents=True, exist_ok=True)