(filename: string)
| 218 | * @param filename File path for the diff |
| 219 | */ |
| 220 | const diffForFile = async (filename: string) => { |
| 221 | const structuredDiff = await structuredDiffForFile(filename) |
| 222 | |
| 223 | if (!structuredDiff) { |
| 224 | return null |
| 225 | } |
| 226 | |
| 227 | const allLines = structuredDiff.chunks |
| 228 | .map((c: { changes: Changes }) => c.changes) |
| 229 | .reduce((a: Changes, b: Changes) => a.concat(b), []) |
| 230 | |
| 231 | return { |
| 232 | before: await config.getFileContents(filename, config.repo, config.baseSHA), |
| 233 | after: await config.getFileContents(filename, config.repo, config.headSHA), |
| 234 | |
| 235 | diff: allLines.map(getContent).join(os.EOL), |
| 236 | |
| 237 | added: allLines.filter(byType("add")).map(getContent).join(os.EOL), |
| 238 | |
| 239 | removed: allLines.filter(byType("del")).map(getContent).join(os.EOL), |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | return { |
| 244 | base: config.baseSHA, |
no test coverage detected