| 72 | } |
| 73 | |
| 74 | export function getDiffContent(input: string, output: string): string | null { |
| 75 | let changes: string[] = []; |
| 76 | for (const change of diffLines(input, output)) { |
| 77 | let lines = change.value.trim().split("\n").slice(0, change.count); |
| 78 | if (lines.length === 0) continue; |
| 79 | if (change.added) { |
| 80 | lines.forEach((line) => { |
| 81 | changes.push(bold(green(line))); |
| 82 | }); |
| 83 | } |
| 84 | if (change.removed) { |
| 85 | lines.forEach((line) => { |
| 86 | changes.push(red(line)); |
| 87 | }); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | return changes.join("\n"); |
| 92 | } |
| 93 | |
| 94 | export const jsClean = (str: string) => { |
| 95 | // Clean all non-alphanumberic values except for dashes |