Skip to content

Commit f6bb010

Browse files
authored
fix(dx/codegen): don't insert module into biome_rule_options/src/lib.rs if it already exists (#8847)
1 parent fd33f86 commit f6bb010

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

xtask/codegen/src/generate_analyzer_rule_options.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,16 @@ pub fn generate_analyzer_rule_options(
5656
fn register_analyzer_rule_options(mod_name: &str) -> Result<()> {
5757
let lib_path = get_analyzer_rule_options_path().join("lib.rs");
5858
let current_lib_content = std::fs::read_to_string(&lib_path)?;
59+
let mod_declaration = format!("pub mod {mod_name};");
60+
if current_lib_content
61+
.lines()
62+
.any(|line| line.trim() == mod_declaration)
63+
{
64+
return Ok(());
65+
}
5966
std::fs::write(
6067
&lib_path,
61-
format!("{current_lib_content}pub mod {mod_name};\n"),
68+
format!("{current_lib_content}{mod_declaration}\n"),
6269
)?;
6370
Ok(())
6471
}

0 commit comments

Comments
 (0)