@@ -3,8 +3,6 @@ import {sprintf} from 'sprintf-js';
3
3
import { info , debug , error , warning , startGroup , endGroup } from '@actions/core' ;
4
4
import { split } from './utils' ;
5
5
6
- export type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' ;
7
- export type Attribute = undefined | 'none' | 'bold' | 'underline' | 'italic' ;
8
6
const COLOR_MAP = {
9
7
'black' : 0 ,
10
8
'red' : 1 ,
@@ -21,6 +19,13 @@ const ATTRIBUTE_MAP = {
21
19
'underline' : 4 ,
22
20
'italic' : 3 ,
23
21
} ;
22
+ type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' ;
23
+ type Attribute = undefined | 'none' | 'bold' | 'underline' | 'italic' ;
24
+ type Setting = {
25
+ color ?: Color ;
26
+ backColor ?: Color ;
27
+ attribute ?: Attribute ;
28
+ } ;
24
29
25
30
/**
26
31
* Logger
@@ -156,21 +161,17 @@ export default class Logger {
156
161
157
162
/**
158
163
* @param {string } string string
159
- * @param {Color|undefined } color color
160
- * @param {Color|undefined } backColor background color
161
- * @param {Attribute|undefined } attribute attribute
164
+ * @param {Setting|undefined } setting setting
162
165
* @return {string } color string
163
166
*/
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 ) ;
167
+ public getColorString = ( string : string , setting ?: Setting ) : string => sprintf ( '\x1b[3%d;4%d;%dm%s\x1b[0m' , COLOR_MAP [ setting ?. color ?? 'white' ] , COLOR_MAP [ setting ?. backColor ?? 'black' ] , ATTRIBUTE_MAP [ setting ?. attribute ?? 'none' ] , string ) ;
165
168
166
169
/**
167
170
* @param {string } string string
168
- * @param {Color|undefined } color color
169
- * @param {Color|undefined } backColor background color
170
- * @param {Attribute|undefined } attribute attribute
171
+ * @param {Setting|undefined } setting setting
171
172
* @return {string } color string
172
173
*/
173
- public c = ( string : string , color ?: Color , backColor ?: Color , attribute ?: Attribute ) : string => this . getColorString ( string , color , backColor , attribute ) ;
174
+ public c = ( string : string , setting ?: Setting ) : string => this . getColorString ( string , setting ) ;
174
175
175
176
/**
176
177
* @return {void }
0 commit comments