@@ -85,6 +85,16 @@ def _ensure_safe_shared_destination(project_path: Path, dest: Path) -> None:
8585 raise ValueError (f"Shared infrastructure destination escapes project root: { label } " ) from None
8686
8787
88+ def _write_shared_text (project_path : Path , dest : Path , content : str ) -> None :
89+ _ensure_safe_shared_destination (project_path , dest )
90+ dest .write_text (content , encoding = "utf-8" )
91+
92+
93+ def _copy_shared_file (project_path : Path , src : Path , dest : Path ) -> None :
94+ _ensure_safe_shared_destination (project_path , dest )
95+ shutil .copy2 (src , dest )
96+
97+
8898def refresh_shared_templates (
8999 project_path : Path ,
90100 * ,
@@ -121,7 +131,7 @@ def refresh_shared_templates(
121131
122132 content = src .read_text (encoding = "utf-8" )
123133 content = IntegrationBase .resolve_command_refs (content , invoke_separator )
124- dst . write_text ( content , encoding = "utf-8" )
134+ _write_shared_text ( project_path , dst , content )
125135 manifest .record_existing (rel )
126136
127137 manifest .save ()
@@ -170,7 +180,7 @@ def install_shared_infra(
170180 continue
171181
172182 dst_path .parent .mkdir (parents = True , exist_ok = True )
173- shutil . copy2 ( src_path , dst_path )
183+ _copy_shared_file ( project_path , src_path , dst_path )
174184 rel = dst_path .relative_to (project_path ).as_posix ()
175185 manifest .record_existing (rel )
176186
@@ -190,7 +200,7 @@ def install_shared_infra(
190200
191201 content = src .read_text (encoding = "utf-8" )
192202 content = IntegrationBase .resolve_command_refs (content , invoke_separator )
193- dst . write_text ( content , encoding = "utf-8" )
203+ _write_shared_text ( project_path , dst , content )
194204 rel = dst .relative_to (project_path ).as_posix ()
195205 manifest .record_existing (rel )
196206
0 commit comments