Skip to content

Commit e5efea4

Browse files
committed
Delete _book folder if it exists from previous runs
1 parent c2b30b8 commit e5efea4

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)