From a96af0d6ead69600eee2c546131545f0a0ef29f4 Mon Sep 17 00:00:00 2001 From: Joscha Date: Fri, 4 Aug 2023 01:47:41 +0200 Subject: [PATCH] Watch migration and template dirs --- build.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index bc5cd0b..be80764 100644 --- a/build.rs +++ b/build.rs @@ -6,7 +6,10 @@ use std::{ use walkdir::WalkDir; +const MIGRATION_DIR: &str = "migrations"; const STATIC_DIR: &str = "static"; +const TEMPLATE_DIR: &str = "templates"; + const STATIC_OUT_DIR: &str = "target/static"; const STATIC_IGNORE_EXT: &[&str] = &["ts"]; @@ -42,13 +45,16 @@ fn copy_static_files() { } fn main() { + watch_dir(MIGRATION_DIR.as_ref()); + watch_dir(STATIC_DIR.as_ref()); + watch_dir(TEMPLATE_DIR.as_ref()); + // Since remove_dir_all fails if the directory doesn't exist, we ensure it // exists before deleting it. This way, we can use the remove_dir_all Result // to ensure the directory was deleted successfully. fs::create_dir_all(STATIC_OUT_DIR).unwrap(); fs::remove_dir_all(STATIC_OUT_DIR).unwrap(); - watch_dir(STATIC_DIR.as_ref()); run_tsc(); copy_static_files(); }