Function
createColor
(
diffType: DiffType,
/**
* TODO(@littledivy): Remove this when we can detect true color terminals. See
* https://github.com/denoland/std/issues/2575.
*/
background = false,
)
Source from the content-addressed store, hash-verified
| 24 | * ``` |
| 25 | */ |
| 26 | export function createColor( |
| 27 | diffType: DiffType, |
| 28 | /** |
| 29 | * TODO(@littledivy): Remove this when we can detect true color terminals. See |
| 30 | * https://github.com/denoland/std/issues/2575. |
| 31 | */ |
| 32 | background = false, |
| 33 | ): (s: string) => string { |
| 34 | switch (diffType) { |
| 35 | case "added": |
| 36 | return (s) => background ? bgGreen(white(s)) : green(bold(s)); |
| 37 | case "removed": |
| 38 | return (s) => background ? bgRed(white(s)) : red(bold(s)); |
| 39 | case "truncation": |
| 40 | return gray; |
| 41 | default: |
| 42 | return white; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Prefixes `+` or `-` in diff output. |
Tested by
no test coverage detected