Skip to content

Commit 61fffc0

Browse files
Merge pull request #8 from technote-space/release/next-v0.1.2
release: v0.1.3
2 parents 738b645 + 0d7ee18 commit 61fffc0

File tree

4 files changed

+44
-28
lines changed

4 files changed

+44
-28
lines changed

__tests__/logger.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,11 @@ describe('Logger', () => {
124124
backColor: 'red',
125125
attribute: 'bold',
126126
})).toBe('\x1b[34;41;1mHello World!!!\x1b[0m');
127-
expect(logger.getColorString('Hello World!!!')).toBe('\x1b[37;40;0mHello World!!!\x1b[0m');
128-
expect(logger.getColorString('Hello World!!!', {color: 'green'})).toBe('\x1b[32;40;0mHello World!!!\x1b[0m');
129-
expect(logger.c('Hello World!!!')).toBe('\x1b[37;40;0mHello World!!!\x1b[0m');
130-
expect(logger.c('Hello World!!!', {color: 'green'})).toBe('\x1b[32;40;0mHello World!!!\x1b[0m');
127+
expect(logger.getColorString('Hello World!!!')).toBe('\x1b[37;40mHello World!!!\x1b[0m');
128+
expect(logger.getColorString('Hello World!!!', {color: 'green'})).toBe('\x1b[32;40mHello World!!!\x1b[0m');
129+
expect(logger.getColorString('Hello World!!!', {color: 'green', attribute: 'italic'})).toBe('\x1b[32;40;3mHello World!!!\x1b[0m');
130+
expect(logger.c('Hello World!!!')).toBe('\x1b[37;40mHello World!!!\x1b[0m');
131+
expect(logger.c('Hello World!!!', {color: 'green'})).toBe('\x1b[32;40mHello World!!!\x1b[0m');
131132
expect(logger.c('Hello World!!!', {
132133
color: 'yellow',
133134
attribute: 'underline',

package.json

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,46 @@
11
{
22
"name": "@technote-space/github-action-log-helper",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "Logging helpers for GitHub Actions.",
5-
"author": {
6-
"name": "Technote",
7-
"email": "technote.space@gmail.com",
8-
"url": "https://technote.space"
9-
},
10-
"license": "MIT",
115
"keywords": [
126
"github",
137
"github actions"
148
],
159
"homepage": "https://github.com/technote-space/github-action-log-helper",
10+
"bugs": {
11+
"url": "https://github.com/technote-space/github-action-log-helper/issues"
12+
},
1613
"repository": {
1714
"type": "git",
1815
"url": "https://github.com/technote-space/github-action-log-helper.git"
1916
},
20-
"bugs": {
21-
"url": "https://github.com/technote-space/github-action-log-helper/issues"
17+
"license": "MIT",
18+
"author": {
19+
"name": "Technote",
20+
"email": "technote.space@gmail.com",
21+
"url": "https://technote.space"
2222
},
2323
"main": "dist/index.js",
2424
"types": "dist/index.d.ts",
2525
"files": [
2626
"dist"
2727
],
28+
"scripts": {
29+
"build": "tsc",
30+
"cover": "jest --coverage",
31+
"lint": "eslint 'src/**/*.ts' '__tests__/**/*.ts' --cache",
32+
"lint:fix": "eslint --fix 'src/**/*.ts' '__tests__/**/*.ts'",
33+
"test": "yarn lint && yarn cover",
34+
"update": "npx npm-check-updates -u && yarn install && yarn upgrade && yarn audit"
35+
},
2836
"dependencies": {
29-
"@actions/core": "^1.2.6"
37+
"@actions/core": "^1.2.6",
38+
"sprintf-js": "^1.1.2"
3039
},
3140
"devDependencies": {
3241
"@commitlint/cli": "^11.0.0",
3342
"@commitlint/config-conventional": "^11.0.0",
34-
"@technote-space/github-action-test-helper": "^0.6.0",
43+
"@technote-space/github-action-test-helper": "^0.6.1",
3544
"@types/jest": "^26.0.14",
3645
"@types/node": "^14.11.5",
3746
"@typescript-eslint/eslint-plugin": "^4.4.0",
@@ -46,13 +55,5 @@
4655
},
4756
"publishConfig": {
4857
"access": "public"
49-
},
50-
"scripts": {
51-
"build": "tsc",
52-
"test": "yarn lint && yarn cover",
53-
"lint": "eslint 'src/**/*.ts' '__tests__/**/*.ts' --cache",
54-
"lint:fix": "eslint --fix 'src/**/*.ts' '__tests__/**/*.ts'",
55-
"cover": "jest --coverage",
56-
"update": "npx npm-check-updates -u && yarn install && yarn upgrade && yarn audit"
5758
}
5859
}

src/logger.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,16 @@ export default class Logger {
166166
* @param {Setting|undefined} setting setting
167167
* @return {string} color string
168168
*/
169-
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);
169+
public getColorString = (string: string, setting?: Setting): string => {
170+
const color = setting?.color ?? 'white';
171+
const backColor = setting?.backColor ?? 'black';
172+
const attribute = setting?.attribute ?? 'none';
173+
if (attribute !== 'none') {
174+
return sprintf('\x1b[3%d;4%d;%dm%s\x1b[0m', COLOR_MAP[color], COLOR_MAP[backColor], ATTRIBUTE_MAP[attribute], string);
175+
}
176+
177+
return sprintf('\x1b[3%d;4%dm%s\x1b[0m', COLOR_MAP[color], COLOR_MAP[backColor], string);
178+
};
170179

171180
/**
172181
* @param {string} string string

yarn.lock

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -766,10 +766,10 @@
766766
dependencies:
767767
"@sinonjs/commons" "^1.7.0"
768768

769-
"@technote-space/github-action-test-helper@^0.6.0":
770-
version "0.6.0"
771-
resolved "https://registry.yarnpkg.com/@technote-space/github-action-test-helper/-/github-action-test-helper-0.6.0.tgz#ff058a3f1467d4ea63b17c01583c6a22906392c8"
772-
integrity sha512-n4YdEmhHvondmffqArdMsNB3iQE0f/GGOoHdT3phaar9vuNl87tYynioiN7W/YLEv/+VDHbtiCnsjNILgN+bKw==
769+
"@technote-space/github-action-test-helper@^0.6.1":
770+
version "0.6.1"
771+
resolved "https://registry.yarnpkg.com/@technote-space/github-action-test-helper/-/github-action-test-helper-0.6.1.tgz#a0fc8a4278145ffaf0561fc87315e81365aa9354"
772+
integrity sha512-EzirRTpYWVKnGOA0fZe73oGt6Fwr+DT0tovx9QlHP4Mxx9xfEOrS0OENeOlz7vyP4NyP9j9OdBvkFtsPvRoIPQ==
773773
dependencies:
774774
"@actions/core" "^1.2.6"
775775
"@actions/github" "^4.0.0"
@@ -4485,6 +4485,11 @@ split2@^2.0.0:
44854485
dependencies:
44864486
through2 "^2.0.2"
44874487

4488+
sprintf-js@^1.1.2:
4489+
version "1.1.2"
4490+
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.2.tgz#da1765262bf8c0f571749f2ad6c26300207ae673"
4491+
integrity sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==
4492+
44884493
sprintf-js@~1.0.2:
44894494
version "1.0.3"
44904495
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"

0 commit comments

Comments
 (0)