Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/format-pretty.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from 'chalk'
import { styleText } from 'node:util'
import * as utils from './utils.js'

const MAX_LINE_COL_LEN = 6
Expand Down Expand Up @@ -61,7 +61,7 @@ function formatLength (msg, opts) {
const l = str.length
if (!opts.detailed) return out
const col = msg.column || 0
const diff = str.slice(0, col) + chalk.red(str.slice(col, l))
const diff = str.slice(0, col) + styleText('red', str.slice(col, l))
return `${out}
${diff}`
}
Expand All @@ -70,7 +70,7 @@ function formatMessage (msg) {
const l = msg.line || 0
const col = msg.column || 0
const pad = utils.rightPad(`${l}:${col}`, MAX_LINE_COL_LEN)
const line = chalk.grey(pad)
const line = styleText('gray', pad)
const id = formatId(msg.id)
const m = msg.message
const icon = msg.level === 'fail'
Expand All @@ -82,5 +82,5 @@ function formatMessage (msg) {
}

function formatId (id) {
return chalk.red(id)
return styleText('red', id)
}
20 changes: 10 additions & 10 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import chalk from 'chalk'
import { styleText } from 'node:util'

export const CHECK = chalk.green('✔')
export const X = chalk.red('✖')
export const WARN = chalk.yellow('⚠')
export const CHECK = styleText('green', '✔')
export const X = styleText('red', '✖')
export const WARN = styleText('yellow', '⚠')

export function rightPad (str, max) {
const diff = max - str.length + 1
Expand All @@ -25,28 +25,28 @@ export function header (sha, status) {
case 'skip':
case 'pass': {
const suffix = status === 'skip' ? ' # SKIPPED' : ''
return `${CHECK} ${chalk.underline(sha)}${suffix}`
return `${CHECK} ${styleText('underline', sha)}${suffix}`
}
case 'fail':
return `${X} ${chalk.underline(sha)}`
return `${X} ${styleText('underline', sha)}`
}
}

export function describeRule (rule, max = 20) {
if (rule.meta && rule.meta.description) {
const desc = rule.meta.description
const title = leftPad(rule.id, max)
console.log(' %s %s', chalk.red(title), chalk.dim(desc))
console.log(' %s %s', styleText('red', title), styleText('dim', desc))
}
}

export function describeSubsystem (subsystems, max = 20) {
if (subsystems) {
for (let sub = 0; sub < subsystems.length; sub = sub + 3) {
console.log('%s %s %s',
chalk.green(leftPad(subsystems[sub] || '', max)),
chalk.green(leftPad(subsystems[sub + 1] || '', max)),
chalk.green(leftPad(subsystems[sub + 2] || '', max))
styleText('green', leftPad(subsystems[sub] || '', max)),
styleText('green', leftPad(subsystems[sub + 1] || '', max)),
styleText('green', leftPad(subsystems[sub + 2] || '', max))
)
}
}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"test-ci": "npm run test && c8 report --reporter=lcov"
},
"dependencies": {
"chalk": "^5.2.0",
"gitlint-parser-node": "^1.1.0",
"nopt": "^7.0.0"
},
Expand Down
Loading