Skip to content

Commit e423d13

Browse files
committed
fix(migrate): emit a single --check when rewriting prettier scripts
1 parent 53edee8 commit e423d13

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

crates/vite_migration/src/prettier.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,15 @@ mod tests {
225225
rewrite_prettier_script("prettier --check --list-different ."),
226226
"vp fmt --check ."
227227
);
228+
229+
// --list-different + --check (the other order) → still a single --check
230+
assert_eq!(
231+
rewrite_prettier_script("prettier --list-different --check ."),
232+
"vp fmt --check ."
233+
);
234+
235+
// two literal --check → still a single --check
236+
assert_eq!(rewrite_prettier_script("prettier --check --check ."), "vp fmt --check .");
228237
}
229238

230239
#[test]

crates/vite_migration/src/script_rewrite.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,14 @@ fn strip_flags_from_suffix(
497497
break;
498498
}
499499
if val == conv.dedup_flag {
500-
conversion_emitted[ci] = true;
500+
// Drop a duplicate if the target flag was already emitted;
501+
// otherwise keep this one and mark it emitted.
502+
if conversion_emitted[ci] {
503+
converted = true;
504+
} else {
505+
conversion_emitted[ci] = true;
506+
}
507+
break;
501508
}
502509
}
503510
if converted {

0 commit comments

Comments
 (0)