about summary refs log tree commit diff
diff options
context:
space:
mode:
authormdinger <mdinger.bugzilla@gmail.com>2015-05-13 00:06:52 -0400
committermdinger <mdinger.bugzilla@gmail.com>2015-05-13 00:06:52 -0400
commite5efea4eb3a75db539fd267ae2574278ec6838bd (patch)
tree1e1ba37c5ba196281d9ffbccd485c15e2e57ca98
parentc2b30b86df6b34ba19e87e63402e43d9e81a64fb (diff)
downloadrust-e5efea4eb3a75db539fd267ae2574278ec6838bd.tar.gz
rust-e5efea4eb3a75db539fd267ae2574278ec6838bd.zip
Delete `_book` folder if it exists from previous runs
-rw-r--r--src/rustbook/build.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/rustbook/build.rs b/src/rustbook/build.rs
index f96704ee128..47bdc9335c4 100644
--- a/src/rustbook/build.rs
+++ b/src/rustbook/build.rs
@@ -183,6 +183,12 @@ impl Subcommand for Build {
             tgt = PathBuf::from(&env::args().nth(3).unwrap());
         }
 
+        // `_book` directory may already exist from previous runs. Check and
+        // delete it if it exists.
+        for entry in try!(fs::read_dir(&cwd)) {
+            let path = try!(entry).path();
+            if path == tgt { try!(fs::remove_dir_all(&tgt)) }
+        }
         try!(fs::create_dir(&tgt));
 
         try!(File::create(&tgt.join("rust-book.css")).and_then(|mut f| {