Skip to content

Commit 7ebd318

Browse files
committed
Add check for .env.local and module bindings generations to only write on changes
1 parent fad2ab3 commit 7ebd318

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

crates/cli/src/subcommands/dev.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ fn upsert_env_db_names_and_hosts(env_path: &Path, server_host_url: &str, databas
315315
} else {
316316
String::new()
317317
};
318+
let original_contents = contents.clone();
318319

319320
for prefix in prefixes {
320321
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
335336
contents.push('\n');
336337
}
337338

338-
fs::write(env_path, contents)?;
339+
if contents != original_contents {
340+
fs::write(env_path, contents)?;
341+
}
339342
Ok(())
340343
}
341344

crates/cli/src/subcommands/generate.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,10 @@ pub async fn exec_ex(
200200
fs::create_dir_all(out_dir.join(parent))?;
201201
}
202202
let path = out_dir.join(fname);
203-
fs::write(&path, code)?;
203+
let contents = fs::read(&path);
204+
if contents.is_err() || contents.is_ok_and(|contents| !code.bytes().eq(contents)) {
205+
fs::write(&path, code)?;
206+
}
204207
paths.insert(path);
205208
}
206209

0 commit comments

Comments
 (0)