| 159 | logger(promise, text, {estimate}); |
| 160 | |
| 161 | const printDiff = (path, beforeContents, afterContents) => { |
| 162 | const patch = createPatch(path, beforeContents, afterContents); |
| 163 | const coloredLines = patch |
| 164 | .split('\n') |
| 165 | .slice(2) // Trim index file |
| 166 | .map((line, index) => { |
| 167 | if (index <= 1) { |
| 168 | return theme.diffHeader(line); |
| 169 | } |
| 170 | switch (line[0]) { |
| 171 | case '+': |
| 172 | return theme.diffAdded(line); |
| 173 | case '-': |
| 174 | return theme.diffRemoved(line); |
| 175 | case ' ': |
| 176 | return line; |
| 177 | case '@': |
| 178 | return null; |
| 179 | case '\\': |
| 180 | return null; |
| 181 | } |
| 182 | }) |
| 183 | .filter(line => line); |
| 184 | console.log(coloredLines.join('\n')); |
| 185 | return patch; |
| 186 | }; |
| 187 | |
| 188 | // Convert an array param (expected format "--foo bar baz") |
| 189 | // to also accept comma input (e.g. "--foo bar,baz") |