( oldFileName: string, newFileName: string, oldStr: string, newStr: string, oldHeader?: string, newHeader?: string, options?: CreatePatchOptionsAbortable | CreatePatchOptionsNonabortable | CreatePatchCallbackNonabortable )
| 525 | options?: CreatePatchOptionsNonabortable |
| 526 | ): string |
| 527 | export function createTwoFilesPatch( |
| 528 | oldFileName: string, |
| 529 | newFileName: string, |
| 530 | oldStr: string, |
| 531 | newStr: string, |
| 532 | oldHeader?: string, |
| 533 | newHeader?: string, |
| 534 | options?: CreatePatchOptionsAbortable | CreatePatchOptionsNonabortable | CreatePatchCallbackNonabortable |
| 535 | ): string | undefined { |
| 536 | if (typeof options === 'function') { |
| 537 | options = {callback: options}; |
| 538 | } |
| 539 | |
| 540 | if (!options?.callback) { |
| 541 | const patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options as any); |
| 542 | if (!patchObj) { |
| 543 | return; |
| 544 | } |
| 545 | return formatPatch(patchObj, options?.headerOptions); |
| 546 | } else { |
| 547 | const {callback} = options; |
| 548 | structuredPatch( |
| 549 | oldFileName, |
| 550 | newFileName, |
| 551 | oldStr, |
| 552 | newStr, |
| 553 | oldHeader, |
| 554 | newHeader, |
| 555 | { |
| 556 | ...options, |
| 557 | callback: patchObj => { |
| 558 | if (!patchObj) { |
| 559 | (callback as CreatePatchCallbackAbortable)(undefined); |
| 560 | } else { |
| 561 | callback(formatPatch(patchObj, options.headerOptions)); |
| 562 | } |
| 563 | } |
| 564 | } |
| 565 | ); |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | /** |
| 570 | * creates a unified diff patch. |
no test coverage detected