Skip to content

Commit

Permalink
defining colored output
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed Aug 17, 2023
1 parent 32bc479 commit 6859f00
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
3 changes: 2 additions & 1 deletion __tests__/functions/trigger-check.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {triggerCheck} from '../../src/functions/trigger-check'
import * as core from '@actions/core'
import {COLORS} from '../../src/functions/colors'

const color = '\u001b[35m' // magenta
const color = COLORS.highlight
const infoMock = jest.spyOn(core, 'info')
const debugMock = jest.spyOn(core, 'debug')

Expand Down
18 changes: 16 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/functions/colors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const COLORS = {
highlight: '\u001b[35m', // magenta
success: '\u001b[32m', // green
error: '\u001b[31m', // red
info: '\u001b[34m', // blue
warning: '\u001b[33m' // yellow
}
9 changes: 7 additions & 2 deletions src/functions/trigger-check.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as core from '@actions/core'
import {COLORS} from './colors'

// A simple function that checks the body of the message against the trigger
// :param body: The content body of the message being checked (String)
Expand All @@ -7,10 +8,14 @@ import * as core from '@actions/core'
export async function triggerCheck(body, trigger) {
// If the trigger is not activated, set the output to false and return with false
if (!body.startsWith(trigger)) {
core.debug(`comment body does not start with trigger: \u001b[35m${trigger}`)
core.debug(
`comment body does not start with trigger: ${COLORS.highlight}${trigger}`
)
return false
}

core.info(`✅ comment body starts with trigger: \u001b[35m${trigger}`)
core.info(
`✅ comment body starts with trigger: ${COLORS.highlight}${trigger}`
)
return true
}

0 comments on commit 6859f00

Please sign in to comment.