Skip to content

Commit 3f66785

Browse files
committed
Add check for .env.local and module bindings generations to only write on changes
1 parent 31a8d5f commit 3f66785

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ 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+
if !path.exists() || fs::read_to_string(&path)? != code {
204+
fs::write(&path, code)?;
205+
}
204206
paths.insert(path);
205207
}
206208

0 commit comments

Comments
 (0)