File tree Expand file tree Collapse file tree 3 files changed +28
-8
lines changed
Expand file tree Collapse file tree 3 files changed +28
-8
lines changed Original file line number Diff line number Diff line change @@ -230,7 +230,7 @@ def setup_frontend(
230230 """
231231 # Create the assets dir if it doesn't exist.
232232 path_ops .mkdir (constants .Dirs .APP_ASSETS )
233- path_ops .cp (
233+ path_ops .copy_tree (
234234 src = str (root / constants .Dirs .APP_ASSETS ),
235235 dest = str (root / prerequisites .get_web_dir () / constants .Dirs .PUBLIC ),
236236 ignore = tuple (f"*.{ ext } " for ext in constants .Reflex .STYLESHEETS_SUPPORTED ),
Original file line number Diff line number Diff line change @@ -42,6 +42,31 @@ def rm(path: str | Path):
4242 path .unlink ()
4343
4444
45+ def copy_tree (
46+ src : str | Path ,
47+ dest : str | Path ,
48+ ignore : tuple [str , ...] | None = None ,
49+ ):
50+ """Copy a directory tree.
51+
52+ Args:
53+ src: The path to the source directory.
54+ dest: The path to the destination directory.
55+ ignore: Ignoring files and directories that match one of the glob-style patterns provided
56+ """
57+ src = Path (src )
58+ dest = Path (dest )
59+ if dest .exists ():
60+ for item in dest .iterdir ():
61+ rm (item )
62+ shutil .copytree (
63+ src ,
64+ dest ,
65+ ignore = shutil .ignore_patterns (* ignore ) if ignore is not None else ignore ,
66+ dirs_exist_ok = True ,
67+ )
68+
69+
4570def cp (
4671 src : str | Path ,
4772 dest : str | Path ,
@@ -65,12 +90,7 @@ def cp(
6590 if not overwrite and dest .exists ():
6691 return False
6792 if src .is_dir ():
68- rm (dest )
69- shutil .copytree (
70- src ,
71- dest ,
72- ignore = shutil .ignore_patterns (* ignore ) if ignore is not None else ignore ,
73- )
93+ copy_tree (src , dest , ignore )
7494 else :
7595 shutil .copyfile (src , dest )
7696 return True
Original file line number Diff line number Diff line change @@ -980,7 +980,7 @@ def initialize_web_directory():
980980 project_hash = get_project_hash ()
981981
982982 console .debug (f"Copying { constants .Templates .Dirs .WEB_TEMPLATE } to { get_web_dir ()} " )
983- path_ops .cp (constants .Templates .Dirs .WEB_TEMPLATE , str (get_web_dir ()))
983+ path_ops .copy_tree (constants .Templates .Dirs .WEB_TEMPLATE , str (get_web_dir ()))
984984
985985 console .debug ("Initializing the web directory." )
986986 initialize_package_json ()
You can’t perform that action at this time.
0 commit comments