Skip to content

Commit 4e3bc93

Browse files
authored
new node custom indicators & escaping (#249)
1 parent 6101373 commit 4e3bc93

File tree

4 files changed

+37
-5
lines changed

4 files changed

+37
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@ jobs:
4141
| `thresholdAll` | ✅ | the minimal average line coverage | 0.8 |
4242
| `thresholdNew` | ✅ | the minimal average new files line coverage | 0.9 |
4343
| `thresholdModified` | ✅ | the minimal average modified files line coverage | 0.0 |
44+
| `passIcon` | ✅ | the indicator to use for files that passed | 🟢 |
45+
| `failIcon` | ✅ | the indicator to use for files that passed | 🔴 |

dist/index.js

Lines changed: 28 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/format.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import {AverageCoverage, Coverage} from './coverage'
22
import {markdownTable} from 'markdown-table'
3+
import * as core from '@actions/core'
34

4-
const passOrFailIndicator = (predicate: boolean): string => (predicate ? '🟢' : '🔴')
5+
const passIcon = core.getInput('passIcon') || '🟢'
6+
const failIcon = core.getInput('failIcon') || '🔴'
7+
const passOrFailIndicator = (predicate: boolean): string => (predicate ? passIcon : failIcon)
58

69
function averageCover(cover: Coverage[]): string {
710
const filterd = cover.filter(file => file.cover >= 0)
@@ -23,7 +26,8 @@ export function formatFilesTable(cover: Coverage[]): {coverTable: string; pass:
2326
...cover.map(coverFile => {
2427
const coverPrecent = `${(coverFile.cover * 100).toFixed()}%`
2528
const indicator = passOrFailIndicator(coverFile.pass)
26-
return [coverFile.file, coverPrecent, indicator]
29+
const formatedFile = coverFile.file.replace("_", "\\_")
30+
return [formatedFile, coverPrecent, indicator]
2731
}),
2832
['**TOTAL**', avgCover, averageIndicator]
2933
],

0 commit comments

Comments
 (0)