Skip to content

Commit 30ca8e0

Browse files
Merge pull request #194 from technote-space/release/v0.6.29
release/v0.6.29
2 parents f004afc + 32f8504 commit 30ca8e0

File tree

4 files changed

+154
-216
lines changed

4 files changed

+154
-216
lines changed

__tests__/logger.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ describe('Logger', () => {
111111
describe('getColorString', () => {
112112
it('should return color string', () => {
113113
expect(logger.getColorString('Hello World!!!', 'blue', 'red', 'bold')).toBe('\x1b[34;41;1mHello World!!!\x1b[0m');
114+
expect(logger.getColorString('Hello World!!!')).toBe('\x1b[37;40;0mHello World!!!\x1b[0m');
114115
expect(logger.getColorString('Hello World!!!', 'green')).toBe('\x1b[32;40;0mHello World!!!\x1b[0m');
116+
expect(logger.c('Hello World!!!')).toBe('\x1b[37;40;0mHello World!!!\x1b[0m');
115117
expect(logger.c('Hello World!!!', 'green')).toBe('\x1b[32;40;0mHello World!!!\x1b[0m');
116118
expect(logger.c('Hello World!!!', 'yellow', undefined, 'underline')).toBe('\x1b[33;40;4mHello World!!!\x1b[0m');
117119
});

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@technote-space/github-action-helper",
3-
"version": "0.6.28",
3+
"version": "0.6.29",
44
"description": "Helper to filter GitHub Action.",
55
"author": "Technote <[email protected]> (https://technote.space)",
66
"license": "MIT",
@@ -28,11 +28,11 @@
2828
"sprintf-js": "^1.1.2"
2929
},
3030
"devDependencies": {
31-
"@technote-space/github-action-test-helper": "^0.0.27",
31+
"@technote-space/github-action-test-helper": "^0.0.28",
3232
"@types/jest": "^24.0.25",
3333
"@types/node": "^13.1.6",
34-
"@typescript-eslint/eslint-plugin": "^2.15.0",
35-
"@typescript-eslint/parser": "^2.15.0",
34+
"@typescript-eslint/eslint-plugin": "^2.16.0",
35+
"@typescript-eslint/parser": "^2.16.0",
3636
"eslint": "^6.8.0",
3737
"jest": "^24.9.0",
3838
"jest-circus": "^24.9.0",

src/logger.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/* 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';
55

66
export type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white';
77
export type Attribute = undefined | 'none' | 'bold' | 'underline' | 'italic';
8-
const COLOR_MAP = {
8+
const COLOR_MAP = {
99
'black': 0,
1010
'red': 1,
1111
'green': 2,
@@ -156,21 +156,21 @@ export default class Logger {
156156

157157
/**
158158
* @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
162162
* @return {string} color string
163163
*/
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);
165165

166166
/**
167167
* @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
171171
* @return {string} color string
172172
*/
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);
174174

175175
/**
176176
* @return {void}

0 commit comments

Comments
 (0)