Skip to content

Commit 2feeb6f

Browse files
committed
.
1 parent a04d4ad commit 2feeb6f

File tree

1 file changed

+9
-7
lines changed
  • packages/swc-plugin-workflow/transform/tests

1 file changed

+9
-7
lines changed

packages/swc-plugin-workflow/transform/tests/errors.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ fn normalize_stderr_files() {
3232
for sub_entry in sub_entries.flatten() {
3333
let sub_path = sub_entry.path();
3434
if sub_path.extension().and_then(|s| s.to_str()) == Some("stderr") {
35-
if let Ok(content) = fs::read_to_string(&sub_path) {
36-
// Normalize: remove all CR, then add CRLF for each line
37-
let normalized = content
38-
.replace("\r\n", "\n") // First normalize CRLF to LF
39-
.replace("\r", "\n") // Handle old Mac-style CR
40-
.replace("\n", "\r\n"); // Convert all LF to CRLF
41-
let _ = fs::write(&sub_path, normalized);
35+
if let Ok(mut content) = fs::read_to_string(&sub_path) {
36+
// On Windows, normalize line endings to LF
37+
// SWC's error handler outputs LF even on Windows
38+
// but Git may check out files with CRLF due to autocrlf
39+
content = content
40+
.replace("\r\n", "\n") // Normalize CRLF to LF
41+
.replace("\r", "\n"); // Handle old Mac-style CR
42+
// Write back with LF line endings
43+
let _ = fs::write(&sub_path, content);
4244
}
4345
}
4446
}

0 commit comments

Comments
 (0)