( tmpOldPath: string, tempNewPath: string, originalParams: ToolParams, modifyContext: ModifyContext<ToolParams>, )
| 81 | } |
| 82 | |
| 83 | function getUpdatedParams<ToolParams>( |
| 84 | tmpOldPath: string, |
| 85 | tempNewPath: string, |
| 86 | originalParams: ToolParams, |
| 87 | modifyContext: ModifyContext<ToolParams>, |
| 88 | ): { updatedParams: ToolParams; updatedDiff: string } { |
| 89 | let oldContent = ''; |
| 90 | let newContent = ''; |
| 91 | |
| 92 | try { |
| 93 | oldContent = fs.readFileSync(tmpOldPath, 'utf8'); |
| 94 | } catch (err) { |
| 95 | if (!isNodeError(err) || err.code !== 'ENOENT') throw err; |
| 96 | oldContent = ''; |
| 97 | } |
| 98 | |
| 99 | try { |
| 100 | newContent = fs.readFileSync(tempNewPath, 'utf8'); |
| 101 | } catch (err) { |
| 102 | if (!isNodeError(err) || err.code !== 'ENOENT') throw err; |
| 103 | newContent = ''; |
| 104 | } |
| 105 | |
| 106 | const updatedParams = modifyContext.createUpdatedParams( |
| 107 | oldContent, |
| 108 | newContent, |
| 109 | originalParams, |
| 110 | ); |
| 111 | const updatedDiff = Diff.createPatch( |
| 112 | path.basename(modifyContext.getFilePath(originalParams)), |
| 113 | oldContent, |
| 114 | newContent, |
| 115 | 'Current', |
| 116 | 'Proposed', |
| 117 | DEFAULT_DIFF_OPTIONS, |
| 118 | ); |
| 119 | |
| 120 | return { updatedParams, updatedDiff }; |
| 121 | } |
| 122 | |
| 123 | function deleteTempFiles(oldPath: string, newPath: string): void { |
| 124 | try { |
no test coverage detected