From 35da8f7310b7eb52e897fe698347b73cb10aed10 Mon Sep 17 00:00:00 2001 From: Adam Christopher Smith Date: Thu, 13 Nov 2025 11:25:30 -0800 Subject: [PATCH] Add check for .env.local and module bindings generations to only write on changes --- crates/cli/src/subcommands/dev.rs | 5 ++++- crates/cli/src/subcommands/generate.rs | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/cli/src/subcommands/dev.rs b/crates/cli/src/subcommands/dev.rs index 868df9c8fe8..202b0b27ddb 100644 --- a/crates/cli/src/subcommands/dev.rs +++ b/crates/cli/src/subcommands/dev.rs @@ -315,6 +315,7 @@ fn upsert_env_db_names_and_hosts(env_path: &Path, server_host_url: &str, databas } else { String::new() }; + let original_contents = contents.clone(); for prefix in prefixes { for (suffix, value) in [("DB_NAME", database_name), ("HOST", server_host_url)] { @@ -335,7 +336,9 @@ fn upsert_env_db_names_and_hosts(env_path: &Path, server_host_url: &str, databas contents.push('\n'); } - fs::write(env_path, contents)?; + if contents != original_contents { + fs::write(env_path, contents)?; + } Ok(()) } diff --git a/crates/cli/src/subcommands/generate.rs b/crates/cli/src/subcommands/generate.rs index 5f6d935bfc5..777ceefa16a 100644 --- a/crates/cli/src/subcommands/generate.rs +++ b/crates/cli/src/subcommands/generate.rs @@ -200,7 +200,9 @@ pub async fn exec_ex( fs::create_dir_all(out_dir.join(parent))?; } let path = out_dir.join(fname); - fs::write(&path, code)?; + if !path.exists() || fs::read_to_string(&path)? != code { + fs::write(&path, code)?; + } paths.insert(path); }