* Check if lines start and end with correct patch markers.
(lines: string[])
| 84 | * Check if lines start and end with correct patch markers. |
| 85 | */ |
| 86 | function checkPatchBoundaries(lines: string[]): void { |
| 87 | if (lines.length === 0) { |
| 88 | throw new ParseError("Empty patch") |
| 89 | } |
| 90 | |
| 91 | const firstLine = lines[0]?.trim() |
| 92 | const lastLine = lines[lines.length - 1]?.trim() |
| 93 | |
| 94 | if (firstLine !== BEGIN_PATCH_MARKER) { |
| 95 | throw new ParseError("The first line of the patch must be '*** Begin Patch'") |
| 96 | } |
| 97 | |
| 98 | if (lastLine !== END_PATCH_MARKER) { |
| 99 | throw new ParseError("The last line of the patch must be '*** End Patch'") |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Parse a single UpdateFileChunk from lines. |