Fix building from scratch

This commit is contained in:
Zoey 2021-08-19 14:00:19 -07:00
parent e91bbc38c5
commit 311a6b40d5
2 changed files with 3 additions and 4 deletions

View file

@ -184,6 +184,9 @@ impl<'a> SiteBuilder<'a> {
/// Builds the Sass styles in the site. /// Builds the Sass styles in the site.
pub fn build_sass(&self) -> anyhow::Result<()> { pub fn build_sass(&self) -> anyhow::Result<()> {
let styles_path = self.build_path.join("styles"); let styles_path = self.build_path.join("styles");
if !styles_path.exists() {
std::fs::create_dir(&styles_path)?;
}
if self.serving { if self.serving {
util::remove_dir_contents(&styles_path) util::remove_dir_contents(&styles_path)
.context("Failed to remove old contents of styles directory")?; .context("Failed to remove old contents of styles directory")?;

View file

@ -4,10 +4,6 @@ use std::path::Path;
/// Simple helper to remove the contents of a directory without removing the directory itself. /// Simple helper to remove the contents of a directory without removing the directory itself.
pub fn remove_dir_contents(path: &Path) -> anyhow::Result<()> { pub fn remove_dir_contents(path: &Path) -> anyhow::Result<()> {
if !path.exists() {
std::fs::create_dir_all(path)?;
return Ok(());
}
for entry in path.read_dir()? { for entry in path.read_dir()? {
let entry = entry?; let entry = entry?;
let path = entry.path(); let path = entry.path();