diamond-in commited on
Commit
9f12f4b
·
verified ·
1 Parent(s): cd2cbe1

Update src/ui/modifier.rs

Browse files
Files changed (1) hide show
  1. src/ui/modifier.rs +8 -3
src/ui/modifier.rs CHANGED
@@ -1,6 +1,11 @@
1
  use std::fs;
 
2
 
3
- pub fn inject_component(name: &str, code: &str) {
4
- let path = format!("./frontend/src/dynamic/{}.tsx", name);
5
- fs::write(path, code).expect("Unable to write UI component");
 
 
 
 
6
  }
 
1
  use std::fs;
2
+ use std::path::Path;
3
 
4
+ pub fn write_dynamic_component(name: &str, code: &str) -> std::io::Result<()> {
5
+ let dir = Path::new("./frontend/src/dynamic");
6
+ if !dir.exists() {
7
+ fs::create_dir_all(dir)?;
8
+ }
9
+ let file_path = dir.join(format!("{}.tsx", name));
10
+ fs::write(file_path, code)
11
  }