(patch: string)
| 157 | } |
| 158 | |
| 159 | function patchLines(patch: string): string[] { |
| 160 | let lines = patch.replace(/\r\n/g, "\n").trim().split("\n"); |
| 161 | const first = lines[0]?.trim(); |
| 162 | const last = lines.at(-1)?.trim(); |
| 163 | if ( |
| 164 | (first === "<<EOF" || first === "<<'EOF'" || first === '<<"EOF"') && |
| 165 | last?.endsWith("EOF") && |
| 166 | lines.length >= 4 |
| 167 | ) { |
| 168 | lines = lines.slice(1, -1); |
| 169 | } |
| 170 | return lines; |
| 171 | } |
| 172 | |
| 173 | function isTopLevelHeader(line: string): boolean { |
| 174 | const trimmed = line.trim(); |