|
1 | 1 | /* eslint-disable @typescript-eslint/no-explicit-any */
|
2 |
| -import { sprintf } from 'sprintf-js'; |
3 |
| -import { info, debug, error, warning, startGroup, endGroup } from '@actions/core'; |
4 |
| -import { split } from './utils'; |
| 2 | +import {sprintf} from 'sprintf-js'; |
| 3 | +import {info, debug, error, warning, startGroup, endGroup} from '@actions/core'; |
| 4 | +import {split} from './utils'; |
5 | 5 |
|
6 | 6 | export type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white';
|
7 | 7 | export type Attribute = undefined | 'none' | 'bold' | 'underline' | 'italic';
|
8 |
| -const COLOR_MAP = { |
| 8 | +const COLOR_MAP = { |
9 | 9 | 'black': 0,
|
10 | 10 | 'red': 1,
|
11 | 11 | 'green': 2,
|
@@ -156,21 +156,21 @@ export default class Logger {
|
156 | 156 |
|
157 | 157 | /**
|
158 | 158 | * @param {string} string string
|
159 |
| - * @param {Color} color color |
160 |
| - * @param {Color} backColor background color |
161 |
| - * @param {Attribute} attribute attribute |
| 159 | + * @param {Color|undefined} color color |
| 160 | + * @param {Color|undefined} backColor background color |
| 161 | + * @param {Attribute|undefined} attribute attribute |
162 | 162 | * @return {string} color string
|
163 | 163 | */
|
164 |
| - public getColorString = (string: string, color: Color, backColor?: Color, attribute?: Attribute): string => sprintf('\x1b[3%d;4%d;%dm%s\x1b[0m', COLOR_MAP[color], COLOR_MAP[backColor ?? 'black'], ATTRIBUTE_MAP[attribute ?? 'none'], string); |
| 164 | + public getColorString = (string: string, color?: Color, backColor?: Color, attribute?: Attribute): string => sprintf('\x1b[3%d;4%d;%dm%s\x1b[0m', COLOR_MAP[color ?? 'white'], COLOR_MAP[backColor ?? 'black'], ATTRIBUTE_MAP[attribute ?? 'none'], string); |
165 | 165 |
|
166 | 166 | /**
|
167 | 167 | * @param {string} string string
|
168 |
| - * @param {Color} color color |
169 |
| - * @param {Color} backColor background color |
170 |
| - * @param {Attribute} attribute attribute |
| 168 | + * @param {Color|undefined} color color |
| 169 | + * @param {Color|undefined} backColor background color |
| 170 | + * @param {Attribute|undefined} attribute attribute |
171 | 171 | * @return {string} color string
|
172 | 172 | */
|
173 |
| - public c = (string: string, color: Color, backColor?: Color, attribute?: Attribute): string => this.getColorString(string, color, backColor, attribute); |
| 173 | + public c = (string: string, color?: Color, backColor?: Color, attribute?: Attribute): string => this.getColorString(string, color, backColor, attribute); |
174 | 174 |
|
175 | 175 | /**
|
176 | 176 | * @return {void}
|
|
0 commit comments