Skip to content

Commit ca225df

Browse files
committed
Rollup merge of rust-lang#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
2 parents b1bd3a3 + e5efea4 commit ca225df

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/rustbook/build.rs

+6
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ impl Subcommand for Build {
183183
tgt = PathBuf::from(&env::args().nth(3).unwrap());
184184
}
185185

186+
// `_book` directory may already exist from previous runs. Check and
187+
// delete it if it exists.
188+
for entry in try!(fs::read_dir(&cwd)) {
189+
let path = try!(entry).path();
190+
if path == tgt { try!(fs::remove_dir_all(&tgt)) }
191+
}
186192
try!(fs::create_dir(&tgt));
187193

188194
try!(File::create(&tgt.join("rust-book.css")).and_then(|mut f| {

0 commit comments

Comments
 (0)