Browse Source

Remove whole public directory and start over

master
Dylan Baker 5 years ago
parent
commit
22bbf46dba
1 changed files with 7 additions and 6 deletions
  1. 7
    6
      src/main.rs

+ 7
- 6
src/main.rs View File

@@ -19,14 +19,15 @@ mod write;
19 19
 fn build() {
20 20
     let cwd = env::current_dir().expect("Couldn't read current directory");
21 21
 
22
-    match fs::create_dir(cwd.join("public")) {
23
-        Ok(_) => {}
24
-        Err(err) => match err.kind() {
25
-            std::io::ErrorKind::AlreadyExists => {}
26
-            _ => panic!(err),
27
-        },
22
+    match fs::read_dir(cwd.join("public")) {
23
+        Ok(_) => {
24
+            fs::remove_dir_all(cwd.join("public")).unwrap();
25
+        }
26
+        Err(_) => {}
28 27
     }
29 28
 
29
+    fs::create_dir(cwd.join("public")).expect("Couldn't create public directory");
30
+
30 31
     let layout_template = fs::read_to_string(&cwd.join("templates").join("layout.html"))
31 32
         .expect("Couldn't find layout template");
32 33
     let post_template = fs::read_to_string(cwd.join("templates").join("post.html"))

Loading…
Cancel
Save