(patch: StructuredPatch | StructuredPatch[])
| 32 | export function winToUnix(patches: StructuredPatch[]): StructuredPatch[]; |
| 33 | export function winToUnix(patch: StructuredPatch | StructuredPatch[]): StructuredPatch | StructuredPatch[]; |
| 34 | export function winToUnix(patch: StructuredPatch | StructuredPatch[]): StructuredPatch | StructuredPatch[] { |
| 35 | if (Array.isArray(patch)) { |
| 36 | // (See comment above equivalent line in unixToWin) |
| 37 | return patch.map(p => winToUnix(p)); |
| 38 | } |
| 39 | |
| 40 | return { |
| 41 | ...patch, |
| 42 | hunks: patch.hunks.map(hunk => ({ |
| 43 | ...hunk, |
| 44 | lines: hunk.lines.map(line => line.endsWith('\r') ? line.substring(0, line.length - 1) : line) |
| 45 | })) |
| 46 | }; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Returns true if the patch consistently uses Unix line endings (or only involves one line and has |
no outgoing calls
no test coverage detected