about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-05-14 19:33:09 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-05-14 19:33:09 +0530
commitca225df7f328a574638ca45ff2c0c15ff8aeabd2 (patch)
treea77eaf82e695f88b0dd463b561a1f293b985512c /src
parentb1bd3a3c5180b2d671e5810cb5211b2d2b456a71 (diff)
parente5efea4eb3a75db539fd267ae2574278ec6838bd (diff)
downloadrust-ca225df7f328a574638ca45ff2c0c15ff8aeabd2.tar.gz
rust-ca225df7f328a574638ca45ff2c0c15ff8aeabd2.zip
Rollup merge of #25354 - mdinger:delete_book, r=steveklabnik
rustbook throws errors if the `_book` folder exists already. Common if you build twice in a row. Identical to https://github.com/steveklabnik/rustbook/issues/20
Diffstat (limited to 'src')
-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| {