Skip to content

Commit

Permalink
Rewrite bold color flag
Browse files Browse the repository at this point in the history
Ditch the defaults for Node v4 compat so this version can be released with npm@5

color() doesn't need a bold flag as you can just pass through an array of color names, eg `['bold', 'white']`.
  • Loading branch information
iarna committed May 4, 2018
1 parent c0d41c7 commit bcf0f68
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ const severityColors = {
}
}

function color (value, colorName, withColor, bold = false) {
if (bold) {
return (colorName && withColor) ? ccs.color(colorName, 'bold') + value + ccs.color('reset') : value
}
function color (value, colorName, withColor) {
return (colorName && withColor) ? ccs.color(colorName) + value + ccs.color('reset') : value
}

function severityLabel (sev, withColor, bold = false) {
return color(severityColors[sev].label, severityColors[sev].color, withColor, bold)
function severityLabel (sev, withColor, bold) {
let colorName = severityColors[sev].color
if (bold) colorName = [colorName, 'bold']
return color(severityColors[sev].label, colorName, withColor)
}

0 comments on commit bcf0f68

Please sign in to comment.